Repository navigation
fix(apps): register nothing when an agent template cannot be read - #34142
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. A read Notes
[DESIGN-REVIEWED] 74fa5e1 Description read[DESCRIPTION-READ] 3c3fb90b99785d3439ff22ae68bec6430442e1accd0cd885f08c6d2b3fb27ba9 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (3 items) — 3 justifiedIntent: when an app agent's template can't be read for a moment, the agent shouldn't get registered with its raw
[FIRST-PRINCIPLES-REVIEWED] 74fa5e1 Description read[DESCRIPTION-READ] 1272ec8a9abd1dedd15dc8e7d27fb95e2fdd79080a79aa65d7179708ae91cf5d That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
buluoray
left a comment
There was a problem hiding this comment.
Approve on b34be91. A read OSError in _render_shipped_agent now logs, reports to io_failures and returns None (same as the write-failure arm), so a template that is locked for a moment is never registered with raw {UV_BIN} placeholders; the only caller already skips on None. Decisive lines: src/kiro_crew/apps/bridges_agents.py:883-889, src/kiro_crew/apps/bridges_agents.py:1003-1007, test/test_app_bridges_agent_configs.py:1401-1420
|
[operator: bolichen97] Closed and reopened with no code change: PR Readiness was waiting on a Code Review run that records its base (the #33337 rule), and only a new pull request event starts one. The close turned auto-merge off; it is re-armed once this re-run is green. |
A read error on an app's agent template made the render hand the unread template path back to the caller. When the error cleared before the caller's own read (a Windows sharing violation, an antivirus scan), the template registered with its literal placeholders and no I/O failure was reported, so no retrying caller tried again. The render now treats a read OSError like its write failure: it logs, reports the template in io_failures and registers nothing. A template that is not UTF-8 keeps its old path. Closes #32688
b34be91 to
74fa5e1
Compare
|
Rebased: main moved in setup.cfg since this head went green (69d3a9a -> c220308); CI re-running. The red |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: a transient OSError reading an app agent template now registers nothing and is reported as a retryable io_failure instead of registering the unrendered template; covered by a new test.
Problem / Motivation
Goal: An app agent whose template file cannot be read for a moment is never registered with its placeholders still in it; the read failure is reported so a retrying caller registers it properly later.
When the gateway could not read an app's agent template at render time, it handed the unread template back to the caller as if no rendering were needed. If the file was readable again a moment later (on Windows, an antivirus scan or a sync client holding a just-extracted file), the caller read the raw template and registered it: the agent config named
{UV_BIN}as its MCP server command, and no failure was reported or logged.Why it matters
The registered agent cannot start its own MCP server, so it cannot reach its tools. The broken config stays until the next registration (a gateway restart, or disabling and re-enabling the app), and nothing in the log points at the cause. Callers that retry on I/O failures saw a success, so they never retried.
Not a goal
_register_agents(handing the template text instead of a path), which would change the helper's return type for every caller.What changed (motivation → approach → change)
A template that could not be read was registered with its raw placeholders when the read worked again a moment later. The cause was the read-error arm of
_render_shipped_agentinapps/bridges_agents.py: it returned the template's own path on anyOSError, assuming the caller's second read of that path would fail too and report it.A read
OSErroris now handled like the write failure in the same function: it logs a warning, adds the template toio_failuresand returnsNone, so nothing is registered and retrying callers try again. AUnicodeDecodeErrorkeeps the old path, because the caller's second read fails the same way and skips the agent.Backwards compatibility
Compatible: a template that reads fine renders and registers as before; only a read that fails at render time changes, from registering whatever the next read finds to registering nothing and reporting the failure, which is what a read that fails a few milliseconds later already did.
Removes nothing: no key, route, file or function is removed; the change is the outcome of one error arm.
Tests
test_a_read_failure_registers_nothing_even_if_the_next_read_succeeds(intest/test_app_bridges_agent_configs.py): the first read of a templated agent raisesPermissionErrorand the next succeeds;_register_agentsregisters nothing, writes no config and reports the template inio_failures.Proof: PROVEN test/test_app_bridges_agent_configs.py::TestRenderFailureIsClassifiedByCause::test_a_read_failure_registers_nothing_even_if_the_next_read_succeeds (head 2df1f7afcee8)
Manual verification
N/A — unit coverage sufficient: the defect is a timing window between two reads of one file, which the test reproduces deterministically by failing the first read.
Related Issues
Closes #32688
Sibling sweep
Swept: git grep -nE "except ((OSError, UnicodeDecodeError|UnicodeDecodeError, OSError))" -- src/kiro_crew/apps/
Siblings: none -- every other match returns a value its caller does not read the same file for again
Pattern harvest
Not generalizable: the defect is one helper returning its unread input for the caller to re-read; no other render or read helper in the app bridges hands an unread path back.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)