Skip to content

feat: expose issue error offsets#1339

Draft
rohan-patnaik wants to merge 1 commit into
cel-expr:masterfrom
rohan-patnaik:rpatnaik/cel-error-location-accessors
Draft

feat: expose issue error offsets#1339
rohan-patnaik wants to merge 1 commit into
cel-expr:masterfrom
rohan-patnaik:rpatnaik/cel-error-location-accessors

Conversation

@rohan-patnaik

@rohan-patnaik rohan-patnaik commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Added Issues.Source() for the source attached to parse/check issues.
  • Added Issues.ErrorOffset() and Issues.ErrorOffsetRange() for raw error positions.

Why

Callers that embed CEL in a larger document can map CEL errors back to their own source ranges without parsing display strings.

Fixes #189.

Testing

  • go test ./common ./cel -run 'TestIssues|TestErrors'

Comment thread cel/env.go
}

// Source returns the source associated with the issues.
func (i *Issues) Source() Source {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Usually the best way to take care of this is to preserve the Source by calling cel.CompileSource and then performing these operations in terms of the Issues and Source values. This is usually more guaranteed to be correct than poking into the internal Issues state.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok ,makes sense. Seems the preferred pattern is for callers to create/preserve a Source, call CompileSource or ParseSource, and then map each issue’s Error.Location through Source.LocationOffset, rather than exposing more of the internal Issues state.

Would you prefer that I close this PR, convert it into docs/example coverage for that usage pattern, or narrow it to a smaller convenience API if there is still a gap worth covering?

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.

Make Errors more useful

2 participants