Validate template fields after rendering in common.ai operators#70338
Merged
Conversation
1fanwang
requested review from
Lee-W,
amoghrajesh,
ashb,
bugraoz93,
gopidesupavan,
jason810496,
jscheffl,
kaxil and
potiuk
as code owners
July 23, 2026 22:03
message_history (AgentOperator) and source_path/file_type (DocumentLoaderOperator) are template fields, rendered after __init__ runs. Both constructors validated them there, acting on the un-rendered Jinja expressions: AgentOperator rejected message_history + enable_hitl_review, and DocumentLoaderOperator enforced the source_path/source_bytes/file_type combination. Move those checks into execute(), which runs after rendering. Constructor-only checks that read no template field (durable/code_mode) stay in __init__. related: apache#70296 Signed-off-by: 1fanwang <1fannnw@gmail.com>
1fanwang
force-pushed
the
fix-common-ai-init
branch
from
July 24, 2026 00:56
3dc0feb to
ed33ae1
Compare
1fanwang
marked this pull request as draft
July 24, 2026 05:47
Signed-off-by: 1fanwang <1fannnw@gmail.com>
1fanwang
marked this pull request as ready for review
July 24, 2026 06:23
Lee-W
approved these changes
Jul 24, 2026
1 task
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.
message_history(AgentOperator) andsource_path/file_type(DocumentLoaderOperator) are template fields, so they are rendered after__init__runs. Both constructors validated them there, acting on the un-rendered Jinja expressions:AgentOperatorrejectedmessage_historycombined withenable_hitl_review. A templatedmessage_history(e.g."{{ ti.xcom_pull(...) }}") is a truthy string in__init__, so the check fired even when it renders to nothing.DocumentLoaderOperatorenforced thesource_path/source_bytes/file_typecombination, so a templatedsource_pathcouldn't resolve before the mutual-exclusivity check ran.Move those checks into
execute(), which runs after rendering. Constructor-only checks that read no template field (durable/code_mode) stay in__init__.related: #70296
Testing Done
Updated the validation tests to drive
execute():test_message_history_with_hitl_review_raisesand DocumentLoader'stest_both_sources_raises/test_neither_source_raises/test_source_bytes_without_file_type_raises/test_empty_bytes_without_file_type_raises. Each fails on the pre-fix source (the constructor raises first, before the operator can render) and passes after. Full suites:test_agent.py+test_document_loader.py= 94 passed.validate_operators_init.pyon both operators exits 0.Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot CLI following the guidelines