Commit 9fd48d7
User
fix(sdk): use build_replacements unresolved set instead of post-scan for curly templates
The curly template formatter raised a false TemplateFormatError when a
substituted value happened to contain {{...}} patterns (e.g. template
examples or code snippets in user input).
Root cause: after substitution, compute_truly_unreplaced() re-scanned
the rendered output for {{...}} patterns and intersected with the
original placeholder set. It could not distinguish between genuinely
unreplaced placeholders and {{...}} patterns injected by substituted
values.
Fix: use the 'unresolved' set already returned by build_replacements()
to detect truly missing variables. This set is computed before
substitution, so it is immune to patterns in substituted values.
Changes:
- types.py: use unresolved from build_replacements instead of
compute_truly_unreplaced
- handlers.py: same fix
- Remove now-unused compute_truly_unreplaced from both files
- Add unit tests covering the false-positive scenario
Fixes #37701 parent a722743 commit 9fd48d7
File tree
3 files changed
+64
-25
lines changed- sdk
- agenta/sdk
- workflows
- tests/pytest/unit
3 files changed
+64
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | 649 | | |
656 | 650 | | |
657 | 651 | | |
| |||
722 | 716 | | |
723 | 717 | | |
724 | 718 | | |
725 | | - | |
| 719 | + | |
726 | 720 | | |
727 | 721 | | |
728 | 722 | | |
729 | 723 | | |
730 | 724 | | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
| 725 | + | |
| 726 | + | |
736 | 727 | | |
737 | 728 | | |
738 | | - | |
| 729 | + | |
739 | 730 | | |
740 | 731 | | |
741 | 732 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | 256 | | |
263 | 257 | | |
264 | 258 | | |
| |||
288 | 282 | | |
289 | 283 | | |
290 | 284 | | |
291 | | - | |
| 285 | + | |
292 | 286 | | |
293 | 287 | | |
294 | 288 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
| 289 | + | |
| 290 | + | |
299 | 291 | | |
300 | 292 | | |
301 | 293 | | |
302 | | - | |
| 294 | + | |
303 | 295 | | |
304 | 296 | | |
305 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments