Commit 64ae4ab
[azure.ai.agents] agent_yaml: name the unresolved placeholders in the post-substitution warning
The post-`init` warning at parameters.go:248 was just:
Warning: Template contains unresolved placeholders.
…with no indication of WHICH placeholders. A user with multiple
unresolved entries had to read the new (4.6/4.7) `Next:` block to
find out, or open agent.yaml and grep for `{{` themselves. The
warning was strictly less useful than the structured guidance it
was meant to flag.
This commit:
1. Promotes the placeholder regex into the agent_yaml package as
`PlaceholderPattern` (exported) and adds an
`ExtractUnresolvedPlaceholders(template string) []string`
helper that returns the deduplicated, sorted list of names.
The regex was previously a private var in
internal/cmd/nextstep/state.go. agent_yaml is the right home
because parameters.go is what DOES the substitution — owning
the placeholder syntax is the same package as owning the
substitution semantics.
2. Updates parameters.go's `injectParameterValues` warning to use
the helper:
Warning: agent.yaml has 3 unresolved placeholder(s):
APP_INSIGHTS_ENDPOINT, TOOLBOX_ENDPOINT,
TOOLBOX_WEB_SEARCH_TOOLS_MCP_ENDPOINT. Edit agent.yaml and
replace each `{{NAME}}` with the actual value before
deploying.
The names are sorted alphabetically (stable across runs;
matches the helper's contract). The numeric prefix lets the
user sanity-check that the count matches what they see in the
Next: block.
3. Refactors `nextstep/state.go` to alias `agent_yaml.PlaceholderPattern`
instead of duplicating the regex. The two call sites (warning +
Next: guidance) MUST agree on what counts as a placeholder, and
a single source-of-truth makes that drift-proof.
The shared regex (`\{\{\s*([^\s{}][^{}]*?)\s*\}\}`) matches everything
the 4.7 nextstep regex matched and nothing more — this is a
zero-behavior-change refactor of nextstep. The visible UX change
is in parameters.go's printed warning only.
Tests:
- `placeholders_test.go` (new) covers 12 cases on
`ExtractUnresolvedPlaceholders`: empty, fully-substituted,
single placeholder, multiple distinct (sorted), duplicates
collapsed, hyphenated/dotted names, whitespace tolerated
inside braces, empty `{{}}` rejected, whitespace-only
`{{ }}` rejected, spaced + unspaced forms of the same name
collapsed, mixed real values and placeholders.
- All pre-existing `injectParameterValues` tests still pass
(substitution logic unchanged).
- All pre-existing nextstep `extractAgentYamlEnvRefs` tests
still pass (regex is byte-for-byte identical to 4.7's via
the alias).
Pre-flight: gofmt clean, vet clean, build clean, full extension
test suite green (cmd 17.4s, doctor 7.6s, nextstep 5.7s,
agent_yaml 6.6s, etc.), golangci-lint 0 issues on the whole
extension, cspell 0 on the 3 production files touched.
Files: 5 changed.
- agent_yaml/placeholders.go (new) — regex + ExtractUnresolved
Placeholders helper.
- agent_yaml/placeholders_test.go (new) — 12 sub-cases.
- agent_yaml/parameters.go — warning now names placeholders.
- nextstep/state.go — placeholderPattern aliased to shared
regex (no other change).
Refs PR Azure#8057. Direct follow-on to 4.6 (placeholder detection)
and 4.7 (multi-category rendering + regex broadening). Closes the
toolbox-sample multi-env-var UX gap end-to-end: the warning names
the placeholders, the Next: block surfaces every fix-up category,
and the user has actionable guidance at both layers.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 94d47f2 commit 64ae4ab
4 files changed
Lines changed: 178 additions & 24 deletions
File tree
- cli/azd/extensions/azure.ai.agents/internal
- cmd/nextstep
- pkg/agents/agent_yaml
Lines changed: 9 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
77 | 67 | | |
78 | 68 | | |
79 | 69 | | |
| |||
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
235 | 243 | | |
236 | | - | |
237 | 244 | | |
238 | 245 | | |
239 | 246 | | |
| |||
243 | 250 | | |
244 | 251 | | |
245 | 252 | | |
246 | | - | |
247 | | - | |
248 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
249 | 260 | | |
250 | 261 | | |
251 | 262 | | |
| |||
Lines changed: 64 additions & 0 deletions
| 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 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
Lines changed: 89 additions & 0 deletions
| 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 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments