feat: support spec:inputs for root pipeline via --input and --inputs-file#1814
Open
gyanranjan wants to merge 3 commits intofirecow:masterfrom
Open
feat: support spec:inputs for root pipeline via --input and --inputs-file#1814gyanranjan wants to merge 3 commits intofirecow:masterfrom
gyanranjan wants to merge 3 commits intofirecow:masterfrom
Conversation
…file Add support for providing spec:inputs values to the root .gitlab-ci.yml pipeline file, not just included files. This closes firecow#1720. Changes: - Add --input KEY=value CLI flag (repeatable) for global inputs - Add --input component:KEY=value syntax for component-specific inputs - Add --inputs-file flag (default: .gitlab-ci-local-inputs.yml) - Pass inputs to root loadYaml() call in parser.ts (was hardcoded {}) - Merge external inputs into all include types (local, project, component, template, remote) - Support structured inputs file with _global and component sections - Fix absolute path handling for --inputs-file Priority order (highest to lowest): 1. Component-specific CLI inputs (--input component:key=value) 2. Global CLI inputs (--input key=value) 3. Component-specific file inputs 4. Global file inputs (_global or flat format) 5. Inline inputs in .gitlab-ci.yml (include: inputs:) 6. Spec defaults Fixes: firecow#1720
Contributor
There was a problem hiding this comment.
4 issues found across 15 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/parser-includes.ts">
<violation number="1" location="src/parser-includes.ts:177">
P1: Component input merge order is incorrect: trailing `cliGlobalInputs` overrides component-specific CLI inputs on key conflicts.</violation>
</file>
<file name="src/argv.ts">
<violation number="1" location="src/argv.ts:226">
P2: Component-specific `--input` parsing is too restrictive (`[\w-]+`) and can misparse valid component names containing `/`, causing inputs to be dropped or assigned to the wrong component.</violation>
<violation number="2" location="src/argv.ts:243">
P1: Global and component inputs share one object namespace, allowing key collisions that can cause runtime errors or overwrite component data.</violation>
<violation number="3" location="src/argv.ts:243">
P1: User-controlled `component`/`key` are assigned into a plain object, allowing `__proto__`-based prototype pollution via `--input` parsing.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if (component) { | ||
| // Component-specific input: store under component namespace | ||
| if (!inputs[component]) inputs[component] = {}; | ||
| inputs[component][key] = parsedValue; |
Contributor
There was a problem hiding this comment.
P1: Global and component inputs share one object namespace, allowing key collisions that can cause runtime errors or overwrite component data.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/argv.ts, line 243:
<comment>Global and component inputs share one object namespace, allowing key collisions that can cause runtime errors or overwrite component data.</comment>
<file context>
@@ -212,6 +217,39 @@ export class Argv {
+ if (component) {
+ // Component-specific input: store under component namespace
+ if (!inputs[component]) inputs[component] = {};
+ inputs[component][key] = parsedValue;
+ } else {
+ // Global input
</file context>
- Fix component input merge order: remove duplicate cliGlobalInputs spread that caused global CLI to override component-specific CLI inputs on key conflicts (P1) - Broaden component name regex to allow '/' for paths like templates/deploy (P2) - Add prototype pollution guard for __proto__, constructor, prototype keys in --input parsing (P1) - Add 7 new tests covering edge cases - Fix existing test that relied on buggy merge order
Author
|
@firecow could you please review this PR when you get a chance? This adds support for root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for providing
spec:inputsvalues to the root.gitlab-ci.ymlpipeline file — not just included files. This closes #1720.Problem
When the root
.gitlab-ci.ymlusesspec:inputs, there was no way to pass values for required inputs (those without adefault). The root file was always loaded with an empty context:Inputs on included files worked fine because
parser-includes.tsforwardedvalue.inputsfrom theinclude:block. But the root file had no equivalent mechanism.Solution
New CLI options
--input KEY=value(repeatable) — provide global inputs--input component:KEY=value— provide component-specific inputs--inputs-file PATH— path to inputs YAML file (default:.gitlab-ci-local-inputs.yml)Inputs file formats
Flat (all inputs are global):
Structured (global + component-specific):
Priority order (highest to lowest)
--input component:key=value)--input key=value)_global:or flat format).gitlab-ci.yml(include: inputs:)Changes
src/argv.tsinputsFilegetter,inputgetter withkey=valueandcomponent:key=valueparsingsrc/index.ts--inputs-fileand--inputyargs optionssrc/parser.tsloadInputs()method; rootloadYaml()now passes{inputs: rootInputs}instead of{}; absolute path support for--inputs-filesrc/parser-includes.tsinputsin opts type; merge logic for global/component-specific inputs across all include typestests/test-cases/component-inputs-cli/tests/test-cases/component-inputs-multiple/tests/test-cases/.gitignore.gitlab-ci-local-inputs.ymlfixture filesTesting
Corner cases verified
--input✅_global:✅--inputs-filepath ✅Example
Fixes #1720
Summary by cubic
Add support for passing
spec:inputsto the root.gitlab-ci.yml, so required root inputs can be provided. Inputs can be set globally or per component via CLI or an inputs file, and are applied across the root and all include types.New Features
--input KEY=value(repeatable) and--input component:KEY=valuefor global and component inputs.--inputs-file PATH(default:.gitlab-ci-local-inputs.yml) with flat or structured formats (_global+ component sections).Bug Fixes
/in component names (e.g.templates/deploy:KEY=value).--inputparsing (__proto__,constructor,prototype).Written for commit 8e761a1. Summary will update on new commits.