fix: fail loudly on an unknown workflow expression filter#3074
Open
doquanghuy wants to merge 1 commit into
Open
fix: fail loudly on an unknown workflow expression filter#3074doquanghuy wants to merge 1 commit into
doquanghuy wants to merge 1 commit into
Conversation
The expression evaluator's filter dispatch fell through to `return value`
for any unregistered filter, so a typo'd or unsupported filter such as
`{{ items | length }}` rendered the value unchanged with no error and the
run completed — a silent wrong result.
Raise a clear ValueError instead, naming the offending filter and the valid
ones, mirroring the strict handling already used for `from_json`. The five
registered filters (default/join/map/contains/from_json) are unchanged; the
`name(arg)` form of an unknown filter is now caught too.
Contributor
Author
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.
Description
Fixes #3073.
The expression evaluator's filter dispatch fell through to
return valuefor any unregistered filter, so a typo'd or unsupported filter — e.g.{{ items | length }}— rendered the value unchanged with no error, and the run completed. A silent wrong result, with nothing pointing at the cause.This makes the unknown-filter path fail loudly: an unrecognized filter raises a clear
ValueErrornaming the offending filter and the valid ones, reusing the same strict-ValueErrorstyle already used forfrom_json(which raises on its mis-wired forms precisely to avoid "silently falling through to the unknown-filter path and returning the unparsed value"). It closes that path in general, consistent with the fail-loud direction of #2957 (fan-out items) and #2961 (from_json).default/join/map/contains/from_json) are unchanged — no behavior change for any valid usage.| length) and thename(arg)form (| upper('x')), which previously also fell through silently.Backward-compat note (calling it out honestly): this turns a previously silent author error into a loud one. Any workflow that today relies on an unknown filter being silently dropped would now error. That passthrough was never intentional (the
from_jsonstrictness comment already names it as a path to avoid), and a scan of the repo's own workflow/template YAMLs found no{{ … | <unknown-filter> }}usage, and the full suite stays green — but flagging it so you can weigh the direction. Happy to rework as a warning-instead-of-raise, or gate it, if you'd prefer.Testing
uv run specify --helpuv sync && uv run pytest— full suite 3912 passed, 59 skipped{{ [1,2,3] | length }}: pre-fix it printedcount=[1, 2, 3]and completed; post-fix the run fails loudly withunknown filter 'length'.Three new tests in
TestExpressions(tests/test_workflows.py):test_filter_unknown_name_raises—| lengthraisesValueError.test_filter_unknown_name_with_args_raises—| upper('x')raises (thename(arg)form).test_registered_filters_unaffected— regression: all five registered filters still work.The two unknown-filter tests are red against
main(DID NOT RAISE), green with the fix.AI Disclosure
This change was authored with Claude Code: the AI drafted the fix and the tests and ran the suite. I discovered the behavior through end-to-end workflow-expression testing, verified the root cause and the red-against-main / green-with-fix tests myself, and reviewed the diff. The fix deliberately reuses the existing
from_jsonerror style rather than inventing a new one.