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

Unhandled error - NoMethodError: undefined method `prev_token' for nil:NilClass #223

Open
jmichaels42 opened this issue Nov 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jmichaels42
Copy link

Describe the Bug

Puppet-lint is not able to validate heredoc syntax

Expected Behavior

The heredoc format succeeds

Steps to Reproduce

Steps to reproduce the behavior:

  1. pkd validate --parallel

Environment

  • Version 11
  • Platform - Windows

Additional Context

Whoops! It looks like puppet-lint has encountered an error that it doesn't
know how to handle. Please open an issue at https://github.com/puppetlabs/puppet-lint
and paste the following output into the issue description.

puppet-lint version: 4.2.4
ruby version: 2.7.8-p225
platform: x64-mingw32
file path: C:/git/puppet/DEVOPS-3355_production_dev_pd_web_sa_SQL_LOGIN/puppet-main/site/profile/manifests/test.pp
file contents:

define profile::iis_app_manage_application_pools () {
  $repository_content      = @("REPO_CONTENT")
    [${repository_name}]
    name=${repository_display_name}
    baseurl=${repository_url}
    enabled=1
    gpgcheck=1
    gpgkey=${repository_url}repodata/repomd.xml.key
    | REPO_CONTENT
}

error:

NoMethodError: undefined method `prev_token' for nil:NilClass
@jmichaels42 jmichaels42 added the bug Something isn't working label Nov 17, 2024
@kruegerkyle95
Copy link

I ran into this as well on linux. I solved it by changes the end of line sequence on the file from CRLF to LF. My simplified example looked like this -

Whoops! It looks like puppet-lint has encountered an error that it doesn't
know how to handle. Please open an issue at https://github.com/puppetlabs/puppet-lint
and paste the following output into the issue description.

puppet-lint version: 4.2.4
ruby version: 3.3.7-p123
platform: x86_64-linux
file path: plans/test_parse.pp
file contents:

# @summary A function that will can find a list of XDCs, one per site, for a given customer
#
# @param tenant_id
# The short domain name of the tenant to perform a vDisk update in. Should follow format et####.
function citrix::xenapp_single_xdc_per_site (
  Pattern['et\d{4}'] $tenant_id,
) {
  $xdc_query = @("XDC_QUERY")
    inventory[certname, facts.xenapp.SiteName]{
      trusted.extensions.pp_role = "xdc" and
      facts.short_domain = "${tenant_id}" and
      facts.xenapp.SiteName is not null
    }
    | XDC_QUERY
}

error:

NoMethodError: undefined method `prev_token' for nil
/usr/local/bundle/gems/puppet-lint-strict_indent-check-3.0.0/lib/puppet-lint/plugins/check_strict_indent.rb:132:in `block in check'
/usr/local/bundle/gems/puppet-lint-strict_indent-check-3.0.0/lib/puppet-lint/plugins/check_strict_indent.rb:49:in `each'
/usr/local/bundle/gems/puppet-lint-strict_indent-check-3.0.0/lib/puppet-lint/plugins/check_strict_indent.rb:49:in `check'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint/checkplugin.rb:21:in `run'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint/checks.rb:61:in `block in run'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint/checks.rb:58:in `each'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint/checks.rb:58:in `run'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint.rb:226:in `run'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint/tasks/puppet-lint.rb:86:in `block (3 levels) in define'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint/tasks/puppet-lint.rb:82:in `each'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint/tasks/puppet-lint.rb:82:in `block (2 levels) in define'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/file_utils_ext.rb:58:in `verbose'
/usr/local/bundle/gems/puppet-lint-4.2.4/lib/puppet-lint/tasks/puppet-lint.rb:75:in `block in define'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/task.rb:281:in `block in execute'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/task.rb:281:in `each'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/task.rb:281:in `execute'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/task.rb:199:in `synchronize'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/task.rb:188:in `invoke'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:188:in `invoke_task'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:138:in `each'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:138:in `block in top_level'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:147:in `run_with_threads'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:132:in `top_level'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:83:in `block in run'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:214:in `standard_exception_handling'
/usr/local/bundle/gems/rake-13.2.1/lib/rake/application.rb:80:in `run'
/usr/local/bundle/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:25:in `load'
/usr/local/bundle/bin/rake:25:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:59:in `load'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:59:in `kernel_load'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:452:in `exec'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor.rb:538:in `dispatch'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:35:in `dispatch'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/cli.rb:29:in `start'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.3/exe/bundle:28:in `block in <top (required)>'
/usr/local/lib/ruby/site_ruby/3.3.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.3.0/gems/bundler-2.6.3/exe/bundle:20:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants