fix(engine): use type-appropriate zero values for optional input defaults#123
Open
PolyphonyRequiem wants to merge 2 commits intomicrosoft:mainfrom
Open
fix(engine): use type-appropriate zero values for optional input defaults#123PolyphonyRequiem wants to merge 2 commits intomicrosoft:mainfrom
PolyphonyRequiem wants to merge 2 commits intomicrosoft:mainfrom
Conversation
…ults
Optional workflow inputs without an explicit `default:` previously
defaulted to Python None, which renders as "None" in templates and
isn't caught by Jinja's `| default()` filter without the boolean flag.
Now uses type-appropriate zero values: "" for string, 0 for number,
false for boolean, [] for array, {} for object. This ensures templates
render cleanly without requiring `| default()` guards or `if X else Y`
workarounds.
Explicit `default:` values in the schema are still honored.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #123 +/- ##
=======================================
Coverage ? 84.84%
=======================================
Files ? 53
Lines ? 7172
Branches ? 0
=======================================
Hits ? 6085
Misses ? 1087
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replace shared [] and {} instances in the class-level _TYPE_ZERO_VALUES
dict with a _zero_value_for_type() method that returns fresh copies for
mutable types (array, object). Prevents potential shared-state bugs if
a caller ever mutates the returned default.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
Optional workflow inputs without an explicit
default:value previously defaulted to PythonNone. This causes two issues:{{ workflow.input.optional_msg }}renders as the literal string"None"instead of empty string| default()doesn't catch None —{{ workflow.input.optional_msg | default("fallback") }}still renders"None"because Jinja'sdefaultfilter only catches undefined, not None (unlessboolean=trueis passed)Reproduction
conductor run test.yaml --input required_id=42Expected: Script outputs
fallback(or empty string)Actual: Script outputs
NoneFix
_apply_input_defaults()now uses type-appropriate zero values instead ofNonefor optional inputs with no declared default:""0false[]{}Explicit
default:values in the schema are still honored. This is a backward-compatible change — templates that checkedif workflow.input.Xwill still work since zero values are falsy.Changes
src/conductor/engine/workflow.py: Add_TYPE_ZERO_VALUESclass constant, update_apply_input_defaults()to use ittests/test_engine/test_workflow.py: Test verifying optional inputs render cleanly (no "None")Testing