Repository navigation
fix(components): keep template inputs reassigned by self-referencing {% set %} - #13756
Sun-Wukhan wants to merge 1 commit into
Conversation
…signs from themselves
|
@Sun-Wukhan is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @Sun-Wukhan, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
My bad! Signing the CLA now! Appreciate you for taking the time to look at this btw. |
|
Hi @Sun-Wukhan, this PR is still waiting for the Contributor License Agreement (CLA) to be signed. Please note that if the CLA isn't signed within the next 24 hours, this PR will be automatically closed. Signing only takes a minute via the link in the |
|
Thanks for signing the CLA, @Sun-Wukhan! 🎉 This PR is now ready for review again and the reviewer has been re-assigned. |
|
Sorry team, signed the CLA just now. |
Why
PromptBuilder,ChatPromptBuilderandOutputAdaptercompute their inputs astemplate_variables - assigned_variables. When a template reassigns a variable from itself, for example{% set query = query | trim %}or{% set documents = documents[:3] %}, the variable is read from the caller before it is set, but_collect_assigned_variablesstill counts it as purely template-internal, so the input socket is dropped and pipelines fail withValueError: Input 'query' not found.Fixes #13753
How
In
_collect_assigned_variables(haystack/utils/jinja2_extensions.py), a{% set %}target is no longer treated as assigned when its own assignment reads it: the names loaded by the assignment's value (or block body) are collected, and any target among them stays a template input. Purely internal assignments, including ones that read other variables, are unchanged.Tests
test_prompt_builder.py,test_chat_prompt_builder.pyandtest_output_adapter.pycovering the self-referencing patterns from the issue, plus direct tests of_extract_template_variables_and_assignmentsintest/utils/test_jinja2_extensions.py.