Commit b048e33
fix(presets): escape installed preset metadata in Rich output (#3826)
* fix(presets): escape installed preset metadata in Rich output
`preset.yml` is user-editable, but the installed-preset display paths
interpolated its fields straight into `console.print`, where Rich parses
`[...]` as a style tag. PR #3773 escaped the *catalog* branch of these
commands; the local branch was left behind, so the same field rendered
correctly from a catalog and incorrectly once installed.
Two failure modes:
- Silent data loss: a description `Does [stuff] nicely` renders as
`Does nicely`.
- Hard crash: an unbalanced tag such as `Broken [/red] tag` raises
`rich.errors.MarkupError`, aborting `preset list`/`preset info` with a
traceback and exit code 1 — the preset cannot be inspected at all.
Escaped the installed branch of `preset list` (name/id/version/
description) and `preset info` (name/id/version/description/author/tags/
repository/license plus the per-template description), and the catalog
branch's tags join that the earlier sweep missed.
`preset resolve` was unescaped throughout: it echoes its own
`template_name` argument, so `preset resolve 'no[/red]such'` crashed on
user input alone. Also escaped the resolved paths, layer sources, and
composition-error message.
Separately, the composition chain's `[{strategy_label}]` was consumed as
a style tag, so every chain line printed a blank label instead of
`[base]`/`[append]`. Escaped the literal bracket as `\[`, matching the
step-graph line in `workflow info`.
Regression tests in `TestInstalledPresetRichMarkup` cover all five
behaviours; each fails before this change.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(presets): cover catalog tags and resolve escapes
Addresses Copilot review feedback on #3826: two escapes added by the
previous commit had no regression assertion, so they could be reverted
with the suite still green.
- `test_info_escapes_catalog_markup` asserted every catalog field except
`tags`; the new tag assertion only exercised an installed preset. Assert
the rendered tags join in the catalog branch too.
- The escapes on `preset resolve`'s resolved path, layer source, and
composition-error message were untested. Add three cases patching
`PresetResolver` to feed markup through the top-layer line, the no-layer
`resolve_with_source` fallback, and a markup-bearing `resolve_content`
exception.
Test-the-test: with `_commands.py` reverted to the pre-fix revision, 9 of
the 10 markup tests fail (was 5); with the fix applied all 10 pass.
A closing tag cannot be embedded in the mocked path — `Path` treats the
`/` as a separator — so the path assertion uses an opening tag for the
swallowing case and the unbalanced tag rides on the adjacent `source`
field on the same line.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Assisted-by: Claude Code (model: claude-opus-5, under direct human supervision)
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent d99170f commit b048e33
2 files changed
Lines changed: 263 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
317 | 320 | | |
318 | 321 | | |
319 | 322 | | |
| 323 | + | |
320 | 324 | | |
321 | 325 | | |
322 | 326 | | |
323 | 327 | | |
324 | 328 | | |
325 | | - | |
326 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
327 | 337 | | |
328 | 338 | | |
329 | 339 | | |
| |||
335 | 345 | | |
336 | 346 | | |
337 | 347 | | |
338 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
339 | 352 | | |
340 | 353 | | |
341 | 354 | | |
| |||
358 | 371 | | |
359 | 372 | | |
360 | 373 | | |
361 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
362 | 382 | | |
363 | 383 | | |
364 | 384 | | |
365 | 385 | | |
366 | | - | |
367 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
368 | 393 | | |
369 | | - | |
| 394 | + | |
370 | 395 | | |
371 | 396 | | |
372 | 397 | | |
| |||
386 | 411 | | |
387 | 412 | | |
388 | 413 | | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
393 | 422 | | |
394 | | - | |
| 423 | + | |
395 | 424 | | |
396 | 425 | | |
397 | | - | |
| 426 | + | |
| 427 | + | |
398 | 428 | | |
399 | 429 | | |
400 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
401 | 434 | | |
402 | 435 | | |
403 | | - | |
| 436 | + | |
404 | 437 | | |
405 | 438 | | |
406 | | - | |
| 439 | + | |
407 | 440 | | |
408 | 441 | | |
409 | 442 | | |
| |||
438 | 471 | | |
439 | 472 | | |
440 | 473 | | |
441 | | - | |
| 474 | + | |
| 475 | + | |
442 | 476 | | |
443 | 477 | | |
444 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12209 | 12209 | | |
12210 | 12210 | | |
12211 | 12211 | | |
| 12212 | + | |
| 12213 | + | |
| 12214 | + | |
| 12215 | + | |
| 12216 | + | |
| 12217 | + | |
| 12218 | + | |
| 12219 | + | |
| 12220 | + | |
| 12221 | + | |
| 12222 | + | |
| 12223 | + | |
| 12224 | + | |
| 12225 | + | |
| 12226 | + | |
| 12227 | + | |
| 12228 | + | |
| 12229 | + | |
| 12230 | + | |
| 12231 | + | |
| 12232 | + | |
| 12233 | + | |
| 12234 | + | |
| 12235 | + | |
| 12236 | + | |
| 12237 | + | |
| 12238 | + | |
| 12239 | + | |
| 12240 | + | |
| 12241 | + | |
| 12242 | + | |
| 12243 | + | |
| 12244 | + | |
| 12245 | + | |
| 12246 | + | |
| 12247 | + | |
| 12248 | + | |
| 12249 | + | |
| 12250 | + | |
| 12251 | + | |
| 12252 | + | |
| 12253 | + | |
| 12254 | + | |
| 12255 | + | |
| 12256 | + | |
| 12257 | + | |
| 12258 | + | |
| 12259 | + | |
| 12260 | + | |
| 12261 | + | |
| 12262 | + | |
| 12263 | + | |
| 12264 | + | |
| 12265 | + | |
| 12266 | + | |
| 12267 | + | |
| 12268 | + | |
| 12269 | + | |
| 12270 | + | |
| 12271 | + | |
| 12272 | + | |
| 12273 | + | |
| 12274 | + | |
| 12275 | + | |
| 12276 | + | |
| 12277 | + | |
| 12278 | + | |
| 12279 | + | |
| 12280 | + | |
| 12281 | + | |
| 12282 | + | |
| 12283 | + | |
| 12284 | + | |
| 12285 | + | |
| 12286 | + | |
| 12287 | + | |
| 12288 | + | |
| 12289 | + | |
| 12290 | + | |
| 12291 | + | |
| 12292 | + | |
| 12293 | + | |
| 12294 | + | |
| 12295 | + | |
| 12296 | + | |
| 12297 | + | |
| 12298 | + | |
| 12299 | + | |
| 12300 | + | |
| 12301 | + | |
| 12302 | + | |
| 12303 | + | |
| 12304 | + | |
| 12305 | + | |
| 12306 | + | |
| 12307 | + | |
| 12308 | + | |
| 12309 | + | |
| 12310 | + | |
| 12311 | + | |
| 12312 | + | |
| 12313 | + | |
| 12314 | + | |
| 12315 | + | |
| 12316 | + | |
| 12317 | + | |
| 12318 | + | |
| 12319 | + | |
| 12320 | + | |
| 12321 | + | |
| 12322 | + | |
| 12323 | + | |
| 12324 | + | |
| 12325 | + | |
| 12326 | + | |
| 12327 | + | |
| 12328 | + | |
| 12329 | + | |
| 12330 | + | |
| 12331 | + | |
| 12332 | + | |
| 12333 | + | |
| 12334 | + | |
| 12335 | + | |
| 12336 | + | |
| 12337 | + | |
| 12338 | + | |
| 12339 | + | |
| 12340 | + | |
| 12341 | + | |
| 12342 | + | |
| 12343 | + | |
| 12344 | + | |
| 12345 | + | |
| 12346 | + | |
| 12347 | + | |
| 12348 | + | |
| 12349 | + | |
| 12350 | + | |
| 12351 | + | |
| 12352 | + | |
| 12353 | + | |
| 12354 | + | |
| 12355 | + | |
| 12356 | + | |
| 12357 | + | |
| 12358 | + | |
| 12359 | + | |
| 12360 | + | |
| 12361 | + | |
| 12362 | + | |
| 12363 | + | |
| 12364 | + | |
| 12365 | + | |
| 12366 | + | |
| 12367 | + | |
| 12368 | + | |
| 12369 | + | |
| 12370 | + | |
| 12371 | + | |
| 12372 | + | |
| 12373 | + | |
| 12374 | + | |
| 12375 | + | |
| 12376 | + | |
| 12377 | + | |
| 12378 | + | |
| 12379 | + | |
| 12380 | + | |
| 12381 | + | |
| 12382 | + | |
| 12383 | + | |
| 12384 | + | |
| 12385 | + | |
| 12386 | + | |
| 12387 | + | |
| 12388 | + | |
| 12389 | + | |
| 12390 | + | |
| 12391 | + | |
| 12392 | + | |
| 12393 | + | |
| 12394 | + | |
| 12395 | + | |
| 12396 | + | |
| 12397 | + | |
| 12398 | + | |
| 12399 | + | |
| 12400 | + | |
| 12401 | + | |
| 12402 | + | |
| 12403 | + | |
| 12404 | + | |
| 12405 | + | |
| 12406 | + | |
| 12407 | + | |
| 12408 | + | |
| 12409 | + | |
| 12410 | + | |
| 12411 | + | |
| 12412 | + | |
| 12413 | + | |
| 12414 | + | |
| 12415 | + | |
| 12416 | + | |
| 12417 | + | |
| 12418 | + | |
| 12419 | + | |
| 12420 | + | |
| 12421 | + | |
0 commit comments