ChatOps run commands fail when Pipeline Execution Policies exist
Summary
ChatOps commands fail with NoMethodError: undefined method '[]' for nil:NilClass when Pipeline Execution Policies (PEP) are configured for a project. The error occurs in the RemoveUnwantedChatJobs pipeline chain component, causing Slack chatops integration to respond with /gitlab failed with the error "dispatch_failed".
Steps to reproduce
- Configure a Pipeline Execution Policy for a GitLab project
- Set up GitLab for Slack integration with chatops enabled
- Execute a chatops command from Slack: /gitlab run
- Observe the error in GitLab logs and failure response in Slack
Example Project
Any project with:
- Pipeline Execution Policy configured
- GitLab for Slack integration enabled
- Valid .gitlab-ci.yml with jobs that can be triggered via chatops
What is the current bug behavior?
- ChatOps command execution fails with
NoMethodError - Slack bot responds with:
/gitlab failed with the error "dispatch_failed"
What is the expected correct behavior?
- ChatOps commands should execute successfully even when Pipeline Execution Policies are configured
- The pipeline should be created with both the requested chatops job and any policy-generated jobs
Relevant logs and/or screenshots
Exception stack
NoMethodError (undefined method `[]' for nil:NilClass):
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs.rb:16:in `block in perform!'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs.rb:15:in `select!'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs.rb:15:in `perform!'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ci/pipeline/chain/sequence.rb:20:in `block in build!'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ci/pipeline/chain/sequence.rb:16:in `each'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ci/pipeline/chain/sequence.rb:16:in `build!'
/opt/gitlab/embedded/service/gitlab-rails/app/services/ci/create_pipeline_service.rb:102:in `execute'
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/ci/pipeline/pipeline_execution_policies/pipeline_context.rb:142:in `block in create_pipeline'
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/ci/pipeline/pipeline_execution_policies/pipeline_context.rb:159:in `with_policy_context'
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/ci/pipeline/pipeline_execution_policies/pipeline_context.rb:133:in `create_pipeline'
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/ci/pipeline/pipeline_execution_policies/pipeline_context.rb:29:in `block in build_policy_pipelines!'
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/ci/pipeline/pipeline_execution_policies/pipeline_context.rb:28:in `each'
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/ci/pipeline/pipeline_execution_policies/pipeline_context.rb:28:in `build_policy_pipelines!'
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/gitlab/ci/pipeline/execution_policies/pipeline_context.rb:16:in `build_policy_pipelines!'
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/ee/gitlab/ci/pipeline/chain/pipeline_execution_policies/evaluate_policies.rb:28:in `perform!'
Output of checks
This bug happens on GitLab.com and Self Managed installations.
Possible fixes
Patch release information for backports
If the bug fix needs to be backported in a patch release to a version under the maintenance policy, please follow the steps on the patch release runbook for GitLab engineers.
Refer to the internal "Release Information" dashboard for information about the next patch release, including the targeted versions, expected release date, and current status.
High-severity bug remediation
To remediate high-severity issues requiring an internal release for single-tenant SaaS instances, refer to the internal release process for engineers.