Skip to content

fix: validate spec:inputs:regex instead of logging a no-op warning#1869

Open
ApoorvaMohan wants to merge 2 commits into
firecow:masterfrom
ApoorvaMohan:fix/remove-spec-inputs-regex-warning
Open

fix: validate spec:inputs:regex instead of logging a no-op warning#1869
ApoorvaMohan wants to merge 2 commits into
firecow:masterfrom
ApoorvaMohan:fix/remove-spec-inputs-regex-warning

Conversation

@ApoorvaMohan
Copy link
Copy Markdown

@ApoorvaMohan ApoorvaMohan commented May 26, 2026

Pull Request: Validate spec:inputs:regex instead of logging a no-op warning

Problem

When spec:inputs:regex is used in a GitLab CI configuration, gitlab-ci-local logs a misleading warning:

WARN spec:inputs:regex is currently not supported via gitlab-ci-local. This will just be a no-op.

The input value is never validated against the regex — it just passes through regardless of whether it matches. This means:

  • Valid inputs produce an unnecessary warning
  • Invalid inputs are silently accepted when they should be rejected

Fixes #1864

Fix

Replaced the no-op warning with actual regex validation using JavaScript's RegExp. The input value is now tested against the provided regex pattern:

  • If the value matches → passes silently (no warning)
  • If the value doesn't match → throws a validation error consistent with GitLab's error format

Changes

src/parser.ts

  • Removed the WARN stderr message
  • Added new RegExp(regex).test(String(inputValue)) assertion that produces a clear error message when validation fails

tests/test-cases/include-inputs/input-templates/regex-validation/ (new)

  • .gitlab-ci-input-template.yml — template with regex: ^v\d+.\d+.\d+$
  • .gitlab-ci.yml — provides invalid input "invalid-version"

tests/test-cases/include-inputs/input-templates/regex-validation-pass/ (new)

  • .gitlab-ci-input-template.yml — template with regex: ^v\d+.\d+.\d+$
  • .gitlab-ci.yml — provides valid input "v1.2.3"

tests/test-cases/include-inputs/integration.test.ts

  • Added test: include-inputs regex validation (invalid) — verifies invalid input produces the expected assertion error
  • Added test: include-inputs regex validation (valid) — verifies valid input passes and renders correctly

Verification

bash
bun run vitest run tests/test-cases/include-inputs/integration.test.ts

All 20 tests pass, including the 2 new regex validation tests.


Summary by cubic

Validate spec:inputs:regex instead of logging a no-op warning. Valid inputs pass silently; invalid inputs or invalid regex patterns now raise clear, GitLab-style errors.

  • Bug Fixes
    • Replaced the warning with real validation: compile with new RegExp(regex) and test String(inputValue).
    • Throw assertion errors when input fails to match and when the regex pattern itself is invalid (no uncaught SyntaxError).
    • Added integration tests for pass, fail, and invalid-pattern cases.

Written for commit 5bd9d65. Summary will update on new commits. Review in cubic

Replace the misleading WARN message with actual regex validation.
Valid inputs now pass silently; invalid inputs produce a validation error.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/parser.ts Outdated
Invalid regex patterns (e.g. '^[unclosed') now produce a clear
configuration error instead of crashing with an uncaught SyntaxError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove obsolete spec:inputs:regex unsupported warning

1 participant