Fail pipeline creation when pipeline variables are too large
What does this MR do and why?
Pipeline variables are stored as a pipeline_variables pipeline artifact. The artifact is built through the pipeline_artifacts_pipeline_variables has_one association, which does not validate on save. When the variables JSON is larger than Ci::PipelineArtifact::FILE_SIZE_LIMIT (10 MiB), the artifact fails its size validation, Rails skips saving it without raising, and pipeline.save! still succeeds. The pipeline runs without its variables and the user sees no error.
This MR checks the JSON size in PipelineVariablesArtifactBuilder before building the artifact. If it is over the limit, pipeline creation fails with a config_error, the same way invalid variables are handled in Chain::Build::Associations:
Failed to build pipeline variables: total size exceeds the limit of 10 MiBThe check is behind the ci_enforce_pipeline_variables_total_size_limit beta feature flag, disabled by default. When the flag is disabled, the previous behavior is kept.
References
- Issue: #633732 (closed)
- Rollout issue: #633591
- Related: !253433 (merged) (adds per-value and count limits, but no total limit, so this cap is still the effective one)
Screenshots or screen recordings
Before:
After:
How to set up and validate locally
-
Use any project with a
.gitlab-ci.ymlthat has at least one job on the default branch, for example:test: script: echo $BIG | wc -c -
Open a Rails console:
gdk rails console -
Enable the feature flag:
Feature.enable(:ci_enforce_pipeline_variables_total_size_limit) -
Create a pipeline with a single pipeline variable just over 10 MiB:
project = Project.find_by_full_path('<your-project-path>') user = User.find_by_username('root') value = 'a' * (Ci::PipelineArtifact::FILE_SIZE_LIMIT + 1.kilobyte) pipeline = Ci::CreatePipelineService .new(project, user, ref: project.default_branch, variables_attributes: [{ key: 'BIG', value: value }]) .execute(:web) .payload -
Inspect the result:
pipeline.created_successfully? pipeline.status pipeline.failure_reason pipeline.error_messages.map(&:content) Ci::PipelineArtifact.where(pipeline_id: pipeline.id, file_type: :pipeline_variables).exists? Ci::Pipeline.find(pipeline.id).variables.to_a pipeline.builds.map(&:name) -
Compare with the expected output:
masterThis MR created_successfully?truefalsestatus"created""failed"failure_reasonnil"config_error"error_messages[]["Failed to build pipeline variables: total size exceeds the limit of 10 MiB"]variables artifact exists? falsefalsevariables[](silently dropped)[]builds["test"](runs withoutBIG)[] -
Optional: run the same steps with a small value (for example
'a' * 100) and check the pipeline is created andCi::Pipeline.find(pipeline.id).variablesreturnsBIG.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

