feat: unify params and output schema handling#1869
Conversation
📝 WalkthroughWalkthroughThis PR extends DAG schema validation to support flexible schema declarations for parameters and step outputs: paths/URLs (strings), inline JSON Schema objects, or booleans. It introduces a shared Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/core/spec/params.go (1)
154-161:⚠️ Potential issue | 🟠 MajorSchema-mode detection here is too global and can drop step params silently.
parseParamValueis also used by step/sub-DAG params parsing, so this branch can reinterpret ordinary maps as schema-backed and return no pairs whenvaluesis absent. That changes behavior outside DAG-rootparamsparsing and can lose user input without an explicit error.💡 Suggested fix direction
-func parseParamValue(ctx BuildContext, input any) ([]paramPair, error) { +func parseParamValue(ctx BuildContext, input any, allowSchemaDeclaration bool) ([]paramPair, error) { ... - case map[string]any: - if _, ok := extractParamsSchemaDeclaration(v); !ok { + case map[string]any: + if !allowSchemaDeclaration { + return parseMapParams(ctx, []any{v}) + } + if _, ok := extractParamsSchemaDeclaration(v); !ok { return parseMapParams(ctx, []any{v}) }Then call DAG-root parsing with
allowSchemaDeclaration=true, and step/sub-DAG parsing withfalse.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/core/spec/params.go` around lines 154 - 161, The current schema-mode detection in parseParamValue (using extractParamsSchemaDeclaration and checking v["values"]) is too global and can silently drop step/sub-DAG params; update parseParamValue to accept an allowSchemaDeclaration bool and only treat maps as schema-backed when allowSchemaDeclaration is true, leaving the existing branch (extractParamsSchemaDeclaration + v["values"] check) guarded by that flag; update callers that parse DAG-root params to pass allowSchemaDeclaration=true and callers for step/sub-DAG params to pass allowSchemaDeclaration=false so ordinary maps are not reinterpreted as schema declarations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@internal/core/spec/params.go`:
- Around line 154-161: The current schema-mode detection in parseParamValue
(using extractParamsSchemaDeclaration and checking v["values"]) is too global
and can silently drop step/sub-DAG params; update parseParamValue to accept an
allowSchemaDeclaration bool and only treat maps as schema-backed when
allowSchemaDeclaration is true, leaving the existing branch
(extractParamsSchemaDeclaration + v["values"] check) guarded by that flag;
update callers that parse DAG-root params to pass allowSchemaDeclaration=true
and callers for step/sub-DAG params to pass allowSchemaDeclaration=false so
ordinary maps are not reinterpreted as schema declarations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cda9360c-7c0a-40c1-b6f1-c18ddb948c16
📒 Files selected for processing (11)
internal/cmn/schema/dag.schema.jsoninternal/cmn/schema/dag_schema_test.gointernal/core/spec/dag_params.gointernal/core/spec/dag_params_test.gointernal/core/spec/params.gointernal/core/spec/schema.gointernal/core/spec/schema_test.gointernal/core/spec/step.gointernal/core/spec/step_output_schema_test.gointernal/intg/output_validation_e2e_test.gointernal/intg/params_validation_issue1252_test.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1869 +/- ##
==========================================
+ Coverage 69.06% 69.13% +0.07%
==========================================
Files 445 445
Lines 54816 54837 +21
==========================================
+ Hits 37859 37912 +53
+ Misses 13589 13574 -15
+ Partials 3368 3351 -17
... and 17 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary
params.schemaandoutput.schemahandling behind a shared schema declaration resolveroutput.schemato use the same declaration shapes as params: string refs, inline objects, and boolean schemasparams: { schema: prod }andparams: { schema: true }by keeping schema-backed params mode opt-in only when the shape is unambiguousWhy
The feature added in #1867 introduced output schema validation, but params and output still used different schema declaration surfaces and separate resolution logic. That made the behavior harder to reason about and left duplicated logic in the spec layer.
Impact
params.schemaandoutput.schemanow share one resolution path and one schema declaration contract. Existing DAGs keep working, including legacy named params that happen to use the keyschema.Validation
go test ./internal/core/spec ./internal/cmn/schema -count=1go test ./internal/intg -run 'TestOutputValidation_|TestIssue1252_' -count=1go test ./internal/runtime -run OutputValidation -count=1Summary by CodeRabbit
New Features
Tests