Deduplicate variable names in Template MissingVariables error - #1539
Open
lntutor wants to merge 1 commit into
Open
Deduplicate variable names in Template MissingVariables error#1539lntutor wants to merge 1 commit into
lntutor wants to merge 1 commit into
Conversation
When a template reuses the same variable (e.g. "Dear $name, from $name")
and it isn't supplied, evaluate() reported it once per textual occurrence
("Missing variables: name, name"). Deduplicate the missing list while
preserving first-seen order so each name is reported once.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N6RtoHuxrDqTUo9Mw9h4Cv
lntutor
force-pushed
the
fix/dedupe-missing-template-vars
branch
from
July 27, 2026 15:05
d551ace to
e9a1f1c
Compare
Author
|
Current head |
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.
When a template reuses the same variable and it isn't supplied, the error currently lists it once per textual occurrence:
A variable is either missing or not, so reporting it N times is incorrect.
Template.interpolatebuildsmissing = [p for p in vars if p not in params]without de-duplicating.This de-duplicates the missing list while preserving first-seen order, so
"Dear $name, from $name"reportsMissing variables: nameand"$a $b $a"reportsMissing variables: a, b. The existing distinct-variable message (Missing variables: one, two) is unchanged.Adds two parametrized cases to
tests/test_templates.py::test_template_evaluate. Fulltests/test_templates.pysuite passes (47).