feat(workflows): add from_json expression filter#2961
Open
doquanghuy wants to merge 1 commit into
Open
Conversation
Step outputs captured as strings could never become typed values in templates - the filter set was default/join/map/contains only, so e.g. a fan-out items: could never consume a step's JSON stdout. Add an arg-less from_json pipe filter with parse-or-raise semantics: invalid JSON or non-string input raises a clear ValueError rather than passing through silently. Fixes github#2960
Contributor
Author
|
@mnriem when you have a moment, would appreciate a review — happy to adjust anything. |
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 #2960.
Adds one arg-less pipe filter to the sandboxed expression evaluator:
_filter_from_jsonparses a JSON string into its typed value (list/dict/scalar). Semantics are parse-or-raise: invalid JSON or non-string input raises a clearValueError— never a silent passthrough, since a parse failure means the pipeline wiring is wrong and silence would hide it. The module docstring's filter list is updated; no other filter or evaluator behavior is touched.This is the smallest unblock for feeding
fan-outitems:(or any condition/arg) from a step that computes a collection at runtime. It composes with — and doesn't preclude — a future declared-outputs:mechanism, which I'm proposing separately.Testing
uv sync && uv run pytest—tests/test_workflows.py210 passedTestExpressions(valid JSON → typed value; invalid JSON raises; non-string raises) — all three are red against currentmain, green with the filter (verified both directions)uvx ruff check src/— cleanuv run specify --help| from_json)AI Disclosure
Code, tests, and this description were authored with AI assistance (Claude); verified by running the repo's test suite and ruff locally in both red and green directions.