Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible encoding regexp match for non-printing characters in place of space #693

Closed
sigv opened this issue Mar 31, 2017 · 4 comments
Closed
Labels
Milestone

Comments

@sigv
Copy link

sigv commented Mar 31, 2017

It looks like when you declare a resource and provide a key parameter, that is not handled nicely. Swap it out for abc and the error goes away.

An example of where it is in use is the puppetlabs/registry module and the registry::value type it has, which has a key parameter there, at least on latest (v1.1.4) which we are using now.

The linter is not able to deal with non-printing characters in places where it expects whitespace. The parser throws out a syntax error - even though Puppet's validation does not complain about the file's contents.


puppet-lint version: 2.2.1
ruby version: 2.1.9-p490
platform: x64-mingw32
file path: ./foo/manifests/bar.pp
file contents:

class foo::bar {
  abc::def { 'tray':
    key => 'A',
  }
}

error:

Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with IBM775 string)
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/plugins/check_whitespace.rb:65:in `scan'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/plugins/check_whitespace.rb:65:in `block in check'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/plugins/check_whitespace.rb:63:in `each'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/plugins/check_whitespace.rb:63:in `each_with_index'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/plugins/check_whitespace.rb:63:in `check'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/checkplugin.rb:21:in `run'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/checks.rb:58:in `block in run'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/checks.rb:56:in `each'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/checks.rb:56:in `run'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint.rb:191:in `run'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/bin.rb:59:in `block in run'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/bin.rb:56:in `each'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/lib/puppet-lint/bin.rb:56:in `run'
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/puppet-lint-2.2.1/bin/puppet-lint:7:in `<top (required)>'
C:/Ruby21-x64/bin/puppet-lint:22:in `load'
C:/Ruby21-x64/bin/puppet-lint:22:in `<main>'
@rodjek rodjek added the bug label Apr 4, 2017
@rnelson0
Copy link
Collaborator

I cannot replicate this with your inline sample (btw there is a non-printing character between key and =>, rather than a space) or the file registry/manifests/value.pp:

# With non-printing character intact:
$ be puppet-lint 693.pp
ERROR: Syntax error (try running `puppet parser validate <file>`) on line 3

# Replace non-printing character with a space:
$ be puppet-lint 693.pp
ERROR: foo::bar not in autoload module layout on line 1
WARNING: class not documented on line 1

# Using the contents of registry/manifests/value.pp
$ be puppet-lint 693.pp
ERROR: registry::value not in autoload module layout on line 42

This is consistent with HEAD, 2.2.1 and the 2.0.0 release, with ruby 2.3.1 via rvm and 2.0.0 via EL7 system ruby.

@sigv
Copy link
Author

sigv commented May 23, 2017

Yes, you are correct - replacing those characters with proper spaces does resolve the linter issue. I had not even noticed they were not actual spaces as the Puppet runs on nodes using the manifests had not complained about them. The error that is produced by the linter suggests running puppet parser validate but the validator does not error out - even setting the verbosity or debugging flags has no effect. So, since Puppet itself does not seem to have any issues parsing the syntax, I believe this should be properly handled by the linter with a proper error or even just a warning, saying that a space character should be put in the place of a non-printing character.

@sigv sigv changed the title incompatible encoding regexp match on key incompatible encoding regexp match for non-printing characters in place of space May 23, 2017
@sigv
Copy link
Author

sigv commented May 23, 2017

Edited the issue's title and description to represent the actual issue, rather than the one I initially reported.

@rnelson0
Copy link
Collaborator

I think this will be addressed successfully in #586, when the actual puppet parser is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants