Pipeline fails to create when using custom scan execution policy with certain hidden jobs
Summary
Pipeline can't be created when using custom scan execution policy with certain hidden jobs.
Steps to reproduce
- Create a new group
- Enable the custom scan experiment in the group settings.
- Create a new project.
- In the project, add the following CI yaml:
.hidden: &hidden - if: $CI_PIPELINE_SOURCE == "web" test: rules: - *hidden script: - echo 'hello'
- Run a manual pipeline. Observe it runs as expected.
- Go to Secure > Policies in the sidebar.
- Click on New Policy, then under
Scan execution policy
click on Select Policy - Enter YAML mode, and put in this policy:
type: scan_execution_policy name: Lint description: Test enabled: true actions: - scan: custom ci_configuration: |- Lint: image: alpine:latest script: - echo Hi rules: - type: pipeline branches: - main
- Merge the policy into the Security Project.
- Go back to to our original project, and attempt to run a manual pipeline.
- We should see an error like this:
- (Workaround) If we change the project's CI yaml to the following, observe the pipeine can be created:
.hidden: &hidden rules: - if: $CI_PIPELINE_SOURCE == "web" test: <<: *hidden script: - echo 'hello'
Example Project
What is the current bug behavior?
Pipeline fails to create with custom scan actions with certain hidden jobs.
What is the expected correct behavior?
Pipeline is created with custom scan actions with certain hidden jobs. Note a customer reports this worked in 16.9.X, but noticed this behaviour started in 16.11.2.
Relevant logs and/or screenshots
exceptions.json
{
"severity": "ERROR",
"time": "2024-05-24T04:00:40.475Z",
"correlation_id": "01HYMC4258ST235DHP46G4D2T5",
"meta.caller_id": "Projects::PipelinesController#create",
"meta.remote_ip": "<REDACTED>",
"meta.feature_category": "continuous_integration",
"meta.user": "root",
"meta.user_id": 1,
"meta.project": "zd532053/project1",
"meta.root_namespace": "zd532053",
"meta.client_id": "user/1",
"exception.class": "TypeError",
"exception.message": "no implicit conversion of Symbol into Integer",
"exception.backtrace": [
"ee/lib/gitlab/ci/config/security_orchestration_policies/processor.rb:145:in `block in clean_up_reserved_stages_jobs'",
"ee/lib/gitlab/ci/config/security_orchestration_policies/processor.rb:144:in `select'",
"ee/lib/gitlab/ci/config/security_orchestration_policies/processor.rb:144:in `clean_up_reserved_stages_jobs'",
"ee/lib/gitlab/ci/config/security_orchestration_policies/processor.rb:38:in `perform'",
"ee/lib/ee/gitlab/ci/config_ee.rb:29:in `process_security_orchestration_policy_includes'",
"ee/lib/ee/gitlab/ci/config_ee.rb:20:in `block in build_config'",
"<internal:kernel>:124:in `then'",
"ee/lib/ee/gitlab/ci/config_ee.rb:20:in `build_config'",
"lib/gitlab/ci/config.rb:129:in `expand_config'",
"lib/gitlab/ci/config.rb:41:in `block in initialize'",
"lib/gitlab/ci/pipeline/logger.rb:27:in `instrument'",
"lib/gitlab/ci/config.rb:40:in `initialize'",
"lib/gitlab/ci/yaml_processor.rb:35:in `new'",
"lib/gitlab/ci/yaml_processor.rb:35:in `parse_config'",
"lib/gitlab/ci/yaml_processor.rb:22:in `block in execute'",
"lib/gitlab/ci/yaml_processor/feature_flags.rb:24:in `with_actor'",
"lib/gitlab/ci/yaml_processor.rb:21:in `execute'",
"lib/gitlab/ci/pipeline/chain/config/process.rb:28:in `block in perform!'",
"lib/gitlab/ci/pipeline/logger.rb:27:in `instrument'",
"lib/gitlab/ci/pipeline/chain/config/process.rb:14:in `perform!'",
"lib/gitlab/ci/pipeline/chain/sequence.rb:20:in `block in build!'",
"lib/gitlab/ci/pipeline/chain/sequence.rb:16:in `each'",
"lib/gitlab/ci/pipeline/chain/sequence.rb:16:in `build!'",
"app/services/ci/create_pipeline_service.rb:94:in `execute'",
"app/controllers/projects/pipelines_controller.rb:85:in `create'",
"actionpack (7.0.8.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'",
"actionpack (7.0.8.1) lib/abstract_controller/base.rb:215:in `process_action'",
"actionpack (7.0.8.1) lib/action_controller/metal/rendering.rb:165:in `process_action'",
"actionpack (7.0.8.1) lib/abstract_controller/callbacks.rb:234:in `block in process_action'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:118:in `block in run_callbacks'",
"ee/lib/gitlab/ip_address_state.rb:10:in `with'",
"ee/app/controllers/ee/application_controller.rb:45:in `set_current_ip_address'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'",
"app/controllers/application_controller.rb:468:in `set_current_admin'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'",
"lib/gitlab/session.rb:11:in `with_session'",
"app/controllers/application_controller.rb:459:in `set_session_storage'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'",
"lib/gitlab/i18n.rb:114:in `with_locale'",
"lib/gitlab/i18n.rb:120:in `with_user_locale'",
"app/controllers/application_controller.rb:450:in `set_locale'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'",
"marginalia (1.11.1) lib/marginalia.rb:109:in `record_query_comment'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'",
"sentry-raven(3.1.2) lib/raven/integrations/rails/controller_transaction.rb:7:in `block in included'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `instance_exec'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'",
"app/controllers/application_controller.rb:443:in `set_current_context'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'",
"sentry-rails (5.10.0) lib/sentry/rails/controller_transaction.rb:28:in `block in sentry_around_action'",
"sentry-ruby (5.10.0) lib/sentry/hub.rb:102:in `with_child_span'",
"sentry-ruby (5.10.0) lib/sentry-ruby.rb:456:in `with_child_span'",
"sentry-rails (5.10.0) lib/sentry/rails/controller_transaction.rb:14:in `sentry_around_action'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:138:in `run_callbacks'",
"actionpack (7.0.8.1) lib/abstract_controller/callbacks.rb:233:in `process_action'",
"actionpack(7.0.8.1) lib/action_controller/metal/rescue.rb:23:in `process_action'",
"actionpack (7.0.8.1) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'",
"activesupport (7.0.8.1) lib/active_support/notifications.rb:206:in `block in instrument'",
"activesupport (7.0.8.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'",
"activesupport (7.0.8.1) lib/active_support/notifications.rb:206:in `instrument'",
"actionpack (7.0.8.1) lib/action_controller/metal/instrumentation.rb:66:in `process_action'",
"actionpack (7.0.8.1) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'",
"activerecord (7.0.8.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'",
"actionpack (7.0.8.1) lib/abstract_controller/base.rb:151:in `process'",
"actionview (7.0.8.1) lib/action_view/rendering.rb:39:in `process'",
"actionpack (7.0.8.1) lib/action_controller/metal.rb:188:in `dispatch'",
"actionpack (7.0.8.1) lib/action_controller/metal.rb:251:in `dispatch'",
"actionpack (7.0.8.1) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'",
"actionpack (7.0.8.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'",
"actionpack (7.0.8.1) lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'",
"actionpack (7.0.8.1) lib/action_dispatch/routing/mapper.rb:48:in `serve'",
"actionpack (7.0.8.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'",
"actionpack (7.0.8.1) lib/action_dispatch/journey/router.rb:32:in `each'",
"actionpack (7.0.8.1) lib/action_dispatch/journey/router.rb:32:in `serve'",
"actionpack (7.0.8.1) lib/action_dispatch/routing/route_set.rb:852:in `call'",
"gitlab-experiment (0.9.1) lib/gitlab/experiment/middleware.rb:19:in `call'",
"flipper (0.26.2) lib/flipper/middleware/memoizer.rb:72:in `memoized_call'",
"flipper (0.26.2) lib/flipper/middleware/memoizer.rb:37:in `call'",
"lib/gitlab/middleware/memory_report.rb:13:in `call'",
"lib/gitlab/middleware/speedscope.rb:13:in `call'",
"lib/gitlab/database/load_balancing/rack_middleware.rb:23:in `call'",
"lib/gitlab/middleware/go.rb:20:in `call'",
"lib/gitlab/etag_caching/middleware.rb:21:in `call'",
"lib/gitlab/middleware/query_analyzer.rb:11:in `block in call'",
"lib/gitlab/database/query_analyzer.rb:40:in `within'",
"lib/gitlab/middleware/query_analyzer.rb:11:in `call'",
"lib/gitlab/middleware/organizations/current.rb:20:in `call'",
"batch-loader (2.0.1) lib/batch_loader/middleware.rb:11:in `call'",
"rack-attack (6.7.0) lib/rack/attack.rb:103:in `call'",
"apollo_upload_server (2.1.5) lib/apollo_upload_server/middleware.rb:19:in `call'",
"lib/gitlab/middleware/multipart.rb:173:in `call'",
"rack-attack (6.7.0) lib/rack/attack.rb:127:in `call'",
"warden (1.2.9) lib/warden/manager.rb:36:in `block in call'",
"warden (1.2.9) lib/warden/manager.rb:34:in `catch'",
"warden (1.2.9) lib/warden/manager.rb:34:in `call'",
"rack-cors (2.0.1) lib/rack/cors.rb:102:in `call'",
"rack (2.2.8.1) lib/rack/tempfile_reaper.rb:15:in `call'",
"rack (2.2.8.1) lib/rack/etag.rb:27:in `call'",
"rack (2.2.8.1) lib/rack/conditional_get.rb:40:in `call'",
"rack (2.2.8.1) lib/rack/head.rb:12:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/http/permissions_policy.rb:38:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/http/content_security_policy.rb:36:in `call'",
"lib/gitlab/middleware/read_only/controller.rb:50:in `call'",
"lib/gitlab/middleware/read_only.rb:18:in `call'",
"lib/gitlab/middleware/unauthenticated_session_expiry.rb:18:in `call'",
"rack (2.2.8.1) lib/rack/session/abstract/id.rb:266:in `context'",
"rack (2.2.8.1) lib/rack/session/abstract/id.rb:260:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/cookies.rb:704:in `call'",
"lib/gitlab/middleware/same_site_cookies.rb:27:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'",
"activesupport (7.0.8.1) lib/active_support/callbacks.rb:99:in `run_callbacks'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'",
"sentry-rails (5.10.0) lib/sentry/rails/rescued_exception_interceptor.rb:12:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'",
"lib/gitlab/middleware/path_traversal_check.rb:35:in `call'",
"lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'",
"sentry-ruby (5.10.0) lib/sentry/rack/capture_exceptions.rb:28:in `block (2 levels) in call'",
"sentry-ruby (5.10.0) lib/sentry/hub.rb:227:in `with_session_tracking'",
"sentry-ruby (5.10.0) lib/sentry-ruby.rb:385:in `with_session_tracking'",
"sentry-ruby (5.10.0) lib/sentry/rack/capture_exceptions.rb:19:in `block incall'",
"sentry-ruby (5.10.0) lib/sentry/hub.rb:59:in `with_scope'",
"sentry-ruby (5.10.0) lib/sentry-ruby.rb:365:in `with_scope'",
"sentry-ruby (5.10.0) lib/sentry/rack/capture_exceptions.rb:18:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/show_exceptions.rb:29:in `call'",
"lib/gitlab/middleware/basic_health_check.rb:25:in `call'",
"lograge (0.11.2) lib/lograge/rails_ext/rack/logger.rb:15:in `call_app'",
"railties (7.0.8.1) lib/rails/rack/logger.rb:25:in `block in call'",
"activesupport (7.0.8.1) lib/active_support/tagged_logging.rb:99:in `block in tagged'",
"activesupport (7.0.8.1) lib/active_support/tagged_logging.rb:37:in `tagged'",
"activesupport (7.0.8.1) lib/active_support/tagged_logging.rb:99:in `tagged'",
"railties (7.0.8.1) lib/rails/rack/logger.rb:25:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'",
"lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'",
"lib/gitlab/middleware/request_context.rb:15:in `call'",
"lib/gitlab/middleware/webhook_recursion_detection.rb:15:in `call'",
"request_store (1.5.1) lib/request_store/middleware.rb:19:in `call'",
"rack (2.2.8.1) lib/rack/method_override.rb:24:in `call'",
"rack (2.2.8.1) lib/rack/runtime.rb:22:in `call'",
"rack-timeout (0.6.3) lib/rack/timeout/core.rb:148:in `block in call'",
"rack-timeout (0.6.3) lib/rack/timeout/support/timeout.rb:19:in `timeout'",
"rack-timeout (0.6.3) lib/rack/timeout/core.rb:147:in `call'",
"config/initializers/fix_local_cache_middleware.rb:11:in `call'",
"lib/gitlab/middleware/compressed_json.rb:44:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/executor.rb:14:in `call'",
"lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'",
"rack (2.2.8.1) lib/rack/sendfile.rb:110:in `call'",
"lib/gitlab/middleware/sidekiq_web_static.rb:20:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/host_authorization.rb:131:in `call'",
"lib/gitlab/metrics/requests_rack_middleware.rb:79:in `call'",
"gitlab-labkit (0.35.1) lib/labkit/middleware/rack.rb:22:in `block in call'",
"gitlab-labkit (0.35.1) lib/labkit/context.rb:35:in `with_context'",
"gitlab-labkit (0.35.1) lib/labkit/middleware/rack.rb:21:in `call'",
"actionpack (7.0.8.1) lib/action_dispatch/middleware/request_id.rb:26:in `call'",
"sentry-raven (3.1.2) lib/raven/integrations/rack.rb:51:in `call'",
"railties (7.0.8.1) lib/rails/engine.rb:530:in `call'",
"railties (7.0.8.1) lib/rails/railtie.rb:226:in `public_send'",
"railties (7.0.8.1) lib/rails/railtie.rb:226:in `method_missing'",
"lib/gitlab/middleware/release_env.rb:13:in `call'",
"rack (2.2.8.1) lib/rack/urlmap.rb:74:in `block in call'",
"rack (2.2.8.1) lib/rack/urlmap.rb:58:in `each'",
"rack (2.2.8.1) lib/rack/urlmap.rb:58:in `call'",
"puma (6.4.0) lib/puma/configuration.rb:272:in `call'",
"puma (6.4.0) lib/puma/request.rb:100:in `block in handle_request'",
"puma (6.4.0) lib/puma/thread_pool.rb:378:in `with_force_shutdown'",
"puma (6.4.0) lib/puma/request.rb:99:in `handle_request'",
"puma (6.4.0) lib/puma/server.rb:443:in `process_client'",
"puma (6.4.0) lib/puma/server.rb:241:in `block in run'",
"puma (6.4.0) lib/puma/thread_pool.rb:155:in `block in spawn_thread'"
],
"user.username": "root",
"tags.program": "web",
"tags.locale": "en",
"tags.feature_category": "continuous_integration",
"tags.correlation_id": "01HYMC4258ST235DHP46G4D2T5",
"extra.project_id": 1,
"extra.sha": "ea3e952228db4603c5fa3c1e86eda2fe87bd9c52"
}
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
# gitlab-rake gitlab:env:info System information System: Ubuntu 22.04 Proxy: no Current User: git Using RVM: no Ruby Version: 3.1.4p223 Gem Version: 3.5.7 Bundler Version:2.5.8 Rake Version: 13.0.6 Redis Version: 7.0.15 Sidekiq Version:7.1.6 Go Version: unknown GitLab information Version: 16.11.2-ee Revision: d210b947e3e Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 14.11 URL: https:// HTTP Clone URL: https:///some-group/some-project.git SSH Clone URL: git@:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.35.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Gitaly - default Address: unix:/var/opt/gitlab/gitaly/gitaly.socket - default Version: 16.11.2 - default Git Version: 2.43.2
Note this issue also occurs in GitLab 17.0
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 14.35.0 ? ... OK (14.35.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Database config exists? ... yes Tables are truncated? ... skipped All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 5/1 ... yes 5/2 ... yes 5/3 ... yes Redis version >= 6.2.14? ... yes Ruby version >= 3.0.6 ? ... yes (3.1.4) Git user has default SSH configuration? ... yes Active users: ... 4 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled) All migrations must be finished before doing a major upgrade ... skipped (Advanced Search is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
-
clean_up_reserved_stages_jobs
function was specifically added in 16.11. See the MR here: Reject project CI jobs on reserved policy stages (!146307 - merged)