Objective
Enhance validation errors with file path and line number context so users can quickly locate and fix problematic configuration in their workflow files.
Context
From discussion #33307: Currently, validation errors don't include workflow file path or line number. Users must manually search their entire workflow to find the problematic field. This is similar to compiler errors that show file:line:column for quick navigation.
Approach
- Extend the frontmatter parser to track line numbers for each field during YAML parsing
- Store line number metadata alongside parsed configuration
- Update
WorkflowValidationError struct to include File and Line fields
- Modify error formatting to display location information in a standard format
- Update validation functions to pass location context when creating errors
Files to Modify
- Update:
pkg/parser/frontmatter_parser.go (track line numbers during parsing)
- Update:
pkg/workflow/errors.go (add File/Line fields to WorkflowValidationError)
- Update:
pkg/workflow/error_formatting.go (format errors with file:line prefix)
- Update:
pkg/workflow/*_validation.go (pass line context when creating errors)
- Update:
pkg/workflow/frontmatter_types.go (store line metadata with config)
Technical Considerations
YAML Line Tracking:
The goccy/go-yaml library (used for YAML 1.1/1.2 compatibility) provides position information through yaml.Node.GetToken(). Use this to track line numbers during parsing.
Example Implementation:
// Store line metadata during parsing
type FieldLocation struct {
File string
Line int
Column int
}
// Enhanced error creation
return NewValidationErrorWithLocation(
field,
value,
reason,
suggestion,
FieldLocation{File: workflowPath, Line: 15, Column: 3}
)
// Error output format
// workflow.md:15:3: validation error in field 'engine'
// Value: 'copiliot'
// Reason: engine 'copiliot' is not valid
// Suggestion: Did you mean 'copilot'?
Acceptance Criteria
Testing Strategy
- Create test workflow with validation error on line 10
- Verify error message includes "workflow.md:10:"
- Test nested fields show correct line numbers
- Test errors without location context still work (graceful fallback)
- Verify all existing tests pass with new error format
- Benchmark parsing performance before/after changes
Edge Cases
- Handle missing file path (e.g., in-memory workflows)
- Handle YAML anchors/aliases that reference different lines
- Handle multiline field values (which line to report?)
- Handle programmatically generated errors (no source location)
Reference
Generated by 📋 Plan Command · ● 12.7M · ◷
Objective
Enhance validation errors with file path and line number context so users can quickly locate and fix problematic configuration in their workflow files.
Context
From discussion #33307: Currently, validation errors don't include workflow file path or line number. Users must manually search their entire workflow to find the problematic field. This is similar to compiler errors that show
file:line:columnfor quick navigation.Approach
WorkflowValidationErrorstruct to includeFileandLinefieldsFiles to Modify
pkg/parser/frontmatter_parser.go(track line numbers during parsing)pkg/workflow/errors.go(add File/Line fields to WorkflowValidationError)pkg/workflow/error_formatting.go(format errors with file:line prefix)pkg/workflow/*_validation.go(pass line context when creating errors)pkg/workflow/frontmatter_types.go(store line metadata with config)Technical Considerations
YAML Line Tracking:
The
goccy/go-yamllibrary (used for YAML 1.1/1.2 compatibility) provides position information throughyaml.Node.GetToken(). Use this to track line numbers during parsing.Example Implementation:
Acceptance Criteria
WorkflowValidationErrorincludes File and Line fieldsfile:line: error messagemake agent-finishsuccessfully before committingTesting Strategy
Edge Cases
Reference
goccy/go-yamldocumentation on position trackingscratchpad/yaml-version-gotchas.mdfor YAML library usage