Serialize CI_JOB_TAGS as valid JSON

What does this MR do and why?

CI_JOB_TAGS is documented as JSON but currently uses Ruby array inspection. Supported control characters can therefore produce Ruby-only escape sequences that JSON parsers reject.

This MR JSON-encodes each tag while preserving the established ordinary representation and tag ordering.

Before

valid supported tag containing U+001B
→ ["prefix\esuffix"]
→ JSON parse fails

After

same tag
→ valid JSON
→ parser returns original tag

Implementation notes

  • Only CI_JOB_TAGS serialization changes.
  • Tag validation and CI YAML grammar are unchanged.
  • Runner behavior and the database are unchanged.
  • The ordinary ["docker", "ruby"] representation remains unchanged.

References

Screenshots or screen recordings

Not applicable. This changes a predefined CI/CD variable's logical value and has no UI.

How to set up and validate locally

This CI YAML reproduces the supported job tag value used by the regression test:

test:
  script: echo test
  tags:
    - "prefix\esuffix"

The regression sets the job's tag list directly and verifies that the builder returns it as a valid JSON string.

Validation results for the final source set:

  • Focused edge regression: 1 example, 0 failures.
  • Complete variables-builder spec: 73 examples, 0 failures.
  • Variables-builder and related tag/config specs: 82 examples, 0 failures.
  • RuboCop: 2 files inspected, no offenses detected.
  • Ruby syntax checks: passed for both changed files.
  • git diff --check: passed.

AI assistance

AI tooling was used to assist with investigation and drafting. The contributor independently reviewed the implementation, reproduced the bug locally, verified the regression test and fix, and takes responsibility for the submitted changes.

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.

Edited by Whale Tech

Merge request reports

Loading
Loading