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

PDK YAML validate issues #1377

Open
jmcdonal opened this issue Jul 12, 2024 · 1 comment
Open

PDK YAML validate issues #1377

jmcdonal opened this issue Jul 12, 2024 · 1 comment
Labels
bug needs-triage Newly created issue that has not been reviewed by a PDK contributor

Comments

@jmcdonal
Copy link

This bug seems similar to #1353 but not exactly the same.

PDK validate fails to complete when checking YAML files.
platform: Ubuntu 22.04.4 LTS
package: pdk 3.2.0.1-1jammy amd64 Puppet Development Kit

$ pdk validate nodes/mail.hi.umn.edu.yaml
pdk (INFO): Using Ruby 3.2.3
pdk (INFO): Using Puppet 8.6.0
pdk (INFO): Running all available validators...
┌ [✔] Running metadata validators ...
└── [✔] Checking metadata syntax (metadata.json tasks/.json).
┌ [✔] Running puppet validators ...
┌ [✔] Running ruby validators ...
└── [✔] Checking Ruby code style (/.rb).
┌ [✔] Running tasks validators ...
├── [✔] Checking task names (tasks/**/
).
└── [✔] Checking task metadata style (tasks/.json).
┌ [|] Running yaml validators ...
└── [|] Checking YAML syntax (**/
.yaml **/*.yml).
/opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/yaml/yaml_syntax_validator.rb:61:in `rescue in validate_target': uninitialized constant PDK::Validate::YAML::YAMLSyntaxValidator::Psych (NameError)

      rescue Psych::SyntaxError => e
             ^^^^^
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/yaml/yaml_syntax_validator.rb:51:in `validate_target'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/internal_ruby_validator.rb:66:in `block in invoke'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/internal_ruby_validator.rb:65:in `each'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/internal_ruby_validator.rb:65:in `invoke'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/validator_group.rb:89:in `block in invoke'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/validator_group.rb:88:in `each'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/validator_group.rb:88:in `invoke'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate.rb:86:in `block (2 levels) in invoke_validators_by_name'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/cli/exec_group.rb:68:in `map'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/cli/exec_group.rb:68:in `exit_code'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate.rb:90:in `invoke_validators_by_name'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/cli/validate.rb:99:in `block (2 levels) in <module:CLI>'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:362:in `run_this'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:298:in `run'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:316:in `run'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/cli.rb:58:in `run'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/exe/pdk:6:in `<top (required)>'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/bin/pdk:25:in `load'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/bin/pdk:25:in `<main>'

/opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/yaml/yaml_syntax_validator.rb:52:in `validate_target': uninitialized constant YAML (NameError)

        ::YAML.safe_load(PDK::Util::Filesystem.read_file(target), permitted_classes: YAML_ALLOWLISTED_CLASSES, permitted_symbols: [], aliases: true)
        ^^^^^^
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/internal_ruby_validator.rb:66:in `block in invoke'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/internal_ruby_validator.rb:65:in `each'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/internal_ruby_validator.rb:65:in `invoke'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/validator_group.rb:89:in `block in invoke'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/validator_group.rb:88:in `each'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate/validator_group.rb:88:in `invoke'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate.rb:86:in `block (2 levels) in invoke_validators_by_name'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/cli/exec_group.rb:68:in `map'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/cli/exec_group.rb:68:in `exit_code'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/validate.rb:90:in `invoke_validators_by_name'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/cli/validate.rb:99:in `block (2 levels) in <module:CLI>'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:362:in `run_this'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:298:in `run'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/cri-2.15.12/lib/cri/command.rb:316:in `run'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/lib/pdk/cli.rb:58:in `run'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/lib/ruby/gems/3.2.0/gems/pdk-3.2.0/exe/pdk:6:in `<top (required)>'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/bin/pdk:25:in `load'
    from /opt/puppetlabs/pdk/private/ruby/3.2.3/bin/pdk:25:in `<main>'

The previous version I had installed was 3.0.1.3-1jammy and had been working fine.

Jeff

@jmcdonal jmcdonal added bug needs-triage Newly created issue that has not been reviewed by a PDK contributor labels Jul 12, 2024
@blotzy
Copy link

blotzy commented Oct 16, 2024

I am getting this issue as well when specifying a specific yaml file to validate.

Works:

pdk validate yaml

Doesn't work

pdk validate yaml data/common.yaml

As a workaround, I added the following to the top of my yaml_syntax_validator.rb in my PDK. Your path my vary. You should see it near the top of your stacktrace
/opt/puppetlabs/pdk/private/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/pdk-3.3.0/lib/pdk/validate/yaml/yaml_syntax_validator.rb

require 'yaml'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage Newly created issue that has not been reviewed by a PDK contributor
Projects
None yet
Development

No branches or pull requests

2 participants