miq_bot icon indicating copy to clipboard operation
miq_bot copied to clipboard

Problem with yamllint configuration file

Open europ opened this issue 6 years ago • 3 comments

Processing a repository which does not have specified rules in .yamllint configuration file will result in:

Called from /root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'
2018-04-21T12:59:14.996Z 3748 TID-grgzknuxk CommitMonitorHandlers::CommitRange::RubocopChecker JID-5e5788c93fcadd6dc8e7ba96 INFO: fail: 3.448 sec
2018-04-21T12:59:14.997Z 3748 TID-grgzknuxk WARN: {"class":"CommitMonitorHandlers::CommitRange::RubocopChecker","args":[2,["265235e76fa59718486c042a0650443d18400e6e"]],"retry":true,"queue":"miq_bot_glacial","jid":"5e5788c93fcadd6dc8e7ba96","created_at":1524315367.5318902,"enqueued_at":1524315551.5467553,"error_message":"undefined method `captures' for nil:NilClass\nDid you mean?  capture","error_class":"NoMethodError","failed_at":1524315372.3904035,"retry_count":1,"retried_at":1524315554.9960437}
2018-04-21T12:59:14.997Z 3748 TID-grgzknuxk WARN: NoMethodError: undefined method `captures' for nil:NilClass
Did you mean?  capture
2018-04-21T12:59:14.997Z 3748 TID-grgzknuxk WARN: /root/miq_bot/lib/linter/yaml.rb:44:in `line_to_hash'
/root/miq_bot/lib/linter/yaml.rb:7:in `block in parse_output'
/root/miq_bot/lib/linter/yaml.rb:7:in `collect'
/root/miq_bot/lib/linter/yaml.rb:7:in `parse_output'
/root/miq_bot/lib/linter/base.rb:31:in `run'
/root/miq_bot/app/workers/concerns/code_analysis_mixin.rb:26:in `run_all_linters'
/root/miq_bot/app/workers/concerns/code_analysis_mixin.rb:12:in `merged_linter_results'
/root/miq_bot/app/workers/commit_monitor_handlers/commit_range/rubocop_checker.rb:25:in `process_branch'
/root/miq_bot/app/workers/commit_monitor_handlers/commit_range/rubocop_checker.rb:19:in `perform'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:152:in `execute_job'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:134:in `block (2 levels) in process'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:128:in `block in invoke'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidetiq-0.7.2/lib/sidetiq/middleware/history.rb:8:in `call'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/logging.rb:32:in `with_context'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/chain.rb:133:in `invoke'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:129:in `block in process'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:168:in `stats'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:128:in `process'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:80:in `process_one'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/processor.rb:68:in `run'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/util.rb:17:in `watchdog'
/root/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.4/lib/sidekiq/util.rb:25:in `block in safe_thread'

NOTE: yamllint has its default rules see here.

The problem starts at line number 7 in lib/linter/yaml.rb:

parsed = lines.collect { |line| line_to_hash(line) }
[1] pry(#<Linter::Yaml>)> lines
=> ["{\"files\":[{\"path\":\"\\\\*\\\\*\",\"offenses\":[{\"severity\":\"fatal\",\"message\":\"Linter::Yaml STDERR:\\n```\\ninvalid config: not a dict\\n\\n```\",\"cop_name\":\"Linter/Yaml\"}]}],\"summary\":{\"offense_count\":1,\"target_file_count\":3,\"inspected_file_count\":3}}"]

in line_to_hash(line) at:

severity, message = severity_message.match(/\[(.*)\] (.*)/).captures

where .captures is called on nil:NilClass:

[3] pry(#<Linter::Yaml>)> severity_message
=> "[{\"severity\":\"fatal\",\"message\":\"Linter::Yaml STDERR:\\n```\\ninvalid config: not a dict\\n\\n```\",\"cop_name\":\"Linter/Yaml\"}]}],\"summary\":{\"offense_count\":1,\"target_file_count\":3,\"inspected_file_count\":3}}"
[4] pry(#<Linter::Yaml>)> severity_message.match(/\[(.*)\] (.*)/)
=> nil

Related issue: https://github.com/ManageIQ/miq_bot/issues/392

europ avatar Apr 21 '18 20:04 europ

@jrafanie does that fix you mentioned today resolve this issue.

JPrause avatar Apr 23 '18 19:04 JPrause

@JPrause it makes it less likely since my PRs add .yamllint to a bunch of repos but any still without that file could hit this issue. So, no, it doesn't fix it.

Note, this is the PR I used locally to blast out the changes to many repos: https://github.com/ManageIQ/manageiq-release/pull/60

jrafanie avatar Apr 23 '18 19:04 jrafanie

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the traige process documentation.

miq-bot avatar Jun 11 '20 22:06 miq-bot