Skip to content

fix(agents): keep proxy-unsafe crew names out of every agent route path - #28628

Merged
iamwhatever merged 1 commit into
fix/agent-name-space-502from
crew/bug-resolve/20083-agent-sibling-routes
Nov 4, 2026
Merged

iamwhatever merged 1 commit into
fix/agent-name-space-502from
crew/bug-resolve/20083-agent-sibling-routes

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A crew whose name has a space (or another character that needs URL encoding) works behind a path-normalising proxy on every crew screen, not only on a plain Save.

Stacked on #19981 (base fix/agent-name-space-502), which moved PUT /api/agents/{name} to a body form. Every sibling route still puts the encoded name in the URL path: /api/agents/Nova%20Sky/capabilities. A path-normalising proxy decodes %20 back to a bare space, the space ends the HTTP request line, and the user sees a 502. #20083 lists them: Delete, the avatar upload (a Save with a new picture) and the avatar image, Approvals (capabilities get/preview/save/detach), the worker kit, and the change-card Apply/Undo steps that call the same routes.

Why it matters

Anyone who names a crewmate with a space ("Nova Sky") and reaches the dashboard through such a proxy cannot open its Approvals or worker kit, cannot change its picture, cannot delete it, and cannot apply or undo a crewmate card for it. #19981 alone fixes only the plain Save.

Not a goal

  • Changing which crew names are allowed.
  • Changing the owner gate or anything a handler does after it reads the name.
  • Removing the path-form routes: plain names and existing clients keep using them.
  • Routes keyed by something other than the crew name (/api/agents/detail/{name} addresses a template, /api/members/{slug} a slug).

What changed (motivation → approach → change)

Symptom: 502 on every crew route for a name with a space behind a path-normalising proxy. Root cause: the name rides the URL path percent-encoded, and the proxy decodes it. Change: such a name never rides the path.

  • Base64url twins. Each crew route that names the crew in its path also answers under /api/agents/b64/{name_b64}.... The segment is unpadded base64url of the UTF-8 name, so it holds only [A-Za-z0-9_-] and a proxy has nothing to decode. Routes: DELETE, GET/POST .../avatar, GET/PUT .../capabilities, POST .../capabilities/preview, POST .../capabilities/detach, GET/PUT .../worker-kit, POST .../worker-kit/preview (src/kiro_crew/dashboard/routes/agents.py).
  • Same handler, same owner gate. Each twin is registered to its path-form route's handler. The handler reads the name through agent_route_name after the owner check (dashboard/agent_name_segment.py). A non-canonical segment (padding, spare bits set, not UTF-8) gets 400 name_segment_invalid, so one name has exactly one spelling (kiro_crew/agent_url_path.py).
  • No shadowing. No twin shares a method and segment pattern with a path-form route, so a crew literally named b64 keeps its own routes. aiohttp tries the longer static prefix first, so this does not rely on registration order; a test pins it.
  • Dashboard callers (website/src/api/agentPath.ts): delete, avatar upload, avatar image, capabilities and worker kit use the twin for such names. Plain names keep the old path. Both sides use the same "needs encoding" rule (Python's quote(safe=""), so !'()* also take the twin).
  • Change cards. crewmate.update Apply/Undo use PUT /api/agents with the name in the body; crewmate.create/import Undo and crewmate.capabilities use the twin. The hook reads a twin as its path-form template (change_cards.route_key) and decodes the name (route_match_info), so step checks, the memory line and the undo identity guards behave the same. The crewmate.update undo guard now also arms on the body-form path.
  • Docs: docs/system-specs/modules/crew-mode.md section "Crew names a proxy would mangle"; two feature-map rows.

Design choice. #20083's action says GETs use a base64url segment and writes take the name in the body. I used the base64url segment for the writes too:

  • POST .../avatar is multipart, so a body name would need a second parsing path.
  • Some proxies drop a DELETE body.
  • One spelling for every route keeps the card hook to one alias table instead of a body-name read per route.

PUT /api/agents keeps the body form #19981 ships. Body-form writes lost on the three points above.

Intended? / Repro

Intended? No. #20083 is a deferred finding from #19981's review: the sibling routes were known to share the bug. On main the paths are built with encodeURIComponent / _q and registered with {name} in the path:

  • src/kiro_crew/dashboard/routes/agents.py:47-55,62,65-66
  • website/src/api/crewCapabilities.ts:62,104, website/src/api/client/agents.ts:566,612, website/src/components/CrewAvatar.tsx:425
  • src/kiro_crew/change_card_catalog.py:256,271, src/kiro_crew/change_card_catalog_plans.py:566,1192,1319

Repro. Crew named Nova Sky, dashboard behind a path-normalising proxy (the #19976 setup). Opening the crew's Approvals sends GET /api/agents/Nova%20Sky/capabilities; the proxy forwards GET /api/agents/Nova Sky/capabilities HTTP/1.1, the space ends the request line, and the user sees a 502. Same for Delete, a new-avatar Save, the worker kit, and applying or undoing a crewmate card. With this change the request is GET /api/agents/b64/Tm92YSBTa3k/capabilities.

Backwards compatibility

Compatible: every path-form route stays registered and unchanged, plain names still use it, and the twins are new paths no client used before.

Removes nothing: only routes and call-site spellings are added; no route, field or record is removed or narrowed.

Tests

  • test/test_agent_b64_routes.py: encoding round trip and every non-canonical refusal; each twin reaches its path-form handler; no twin can shadow a path-form route, and a crew named b64 resolves to its own routes; non-owner 403 on every twin; owner with a bad segment gets 400; card plans for both name forms; hook aliasing and name decoding.
  • test/test_agents_endpoints_owner_auth.py: the two mutating twins in handlers.agents join the owner-gate floor.
  • test/test_change_cards_identity.py: the crewmate.update undo guard arms on the body-form PUT /api/agents.
  • website/src/api/agentPath.test.ts: path form for plain names; base64url (UTF-8, URL-safe) for others, including !'()*.

Proof: not provable -- other: no local test runs on this host; CI runs the suite and each new test asserts the new spelling.

Local static gates: black, isort, flake8, mypy (changed modules), tsc, eslint.

Manual verification

N/A: no proxy setup on this host. The request spelling is pinned by unit tests on both client and server, and the twins reuse the existing handlers unchanged.

Screenshots / video

Why no screenshot: Only the request URLs change; every screen, including the avatar image, renders exactly as before.

Related Issues

Fixes #20083. Stacked on #19981 (fixes #19976).

Sibling sweep

Swept: git grep -nE "/api/agents/['"]? ?+|/api/agents/${|/api/agents/{" -- src website/src
Sibling: website/src/api/crewCapabilities.ts -- changed here
Sibling: website/src/api/client/agents.ts -- changed here
Sibling: website/src/components/CrewAvatar.tsx -- changed here
Sibling: src/kiro_crew/change_card_catalog.py -- changed here
Sibling: src/kiro_crew/change_card_catalog_plans.py -- changed here
Sibling: src/kiro_crew/dashboard/routes/agents.py -- changed here

Pattern harvest

Rule candidate: review-prompt
Pattern: a user-chosen name placed in a URL path segment with encodeURIComponent; use agentPath or a body field instead.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083
@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 2, 2026 22:24
@CrysisDeu
CrysisDeu requested review from mbriones98 and removed request for a team November 2, 2026 22:24
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 6a10f8ec4f12e9e0f09e35eaf7ffddce127e4189 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6a10f8e

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 6a10f8ec4f12e9e0f09e35eaf7ffddce127e4189 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 6a10f8ec4f12e9e0f09e35eaf7ffddce127e4189 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check: the diff only changes the request URLs the dashboard builds. It adds or changes no visible control, string or state, so the missing blind read leaves nothing unreviewed.

[UX-REVIEWED] 6a10f8e

Description read

[DESCRIPTION-READ] 370d8a486b82d4e46e45dd6eb652dd38eb33c9ef6ebba150b1c46c162271a26b

That sha256 names everything this verdict read: the PR description, plus the 3 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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 6a10f8ec4f12e9e0f09e35eaf7ffddce127e4189 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: each base64url route reuses its existing handler and owner gate, the only change is where the name is read from, nothing is removed, and the routes can be deleted later without migrating anything.

Notes

  • route_match_info turns a bad name_b64 into name="" before the handler returns its 400. That means _before_value runs a snapshot lookup for the empty name. Returning early from the middleware when decode_agent_name returns None would keep the change-card hook from ever recording against "".
  • The "needs encoding" rule is copied in agent_url_path.needs_proxy_safe_path and agentPath.ts (the extra !'()* check). Only unit tests on each side keep them matched; no test checks the two against each other. A shared test-vector list read by both suites would catch drift.

[DESIGN-REVIEWED] 6a10f8e

Description read

[DESCRIPTION-READ] 360c8256fc0298206a907e05b29a5fcc953b38df4b1d4f2f0517484963314ebb

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 6a10f8ec4f12e9e0f09e35eaf7ffddce127e4189 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

This is a fix with a linked issue (#20083) and a written repro. Every new twin route has a caller, and the change fixes the cause: crew names that need encoding no longer go in the URL path.

Notes

  • Item 10 — symptom-level: two "needs encoding" rules now exist. agentPath and the server's agent_record_write use quote(safe=""), so they also catch !'()*. The dashboard's own Save still uses if (encodeURIComponent(name) !== name) (website/src/api/client/agents.ts:561). For a name like Bob's, a change-card Apply sends the name in the body while a dashboard Save puts it in the path. Subtraction: replace that predicate with the one agentPath uses and delete the inline rule.

What this change ships

Inventory (10 items) — 9 justified

Intent: let someone whose crewmate's name has a space use every crew screen behind a path-normalising proxy. FIX.

  1. Deleting a crewmate with a spaced name no longer 502s — justified
  2. Changing the picture, and showing it, works for such names — justified
  3. Approvals (get/preview/save/detach) works for such names — justified
  4. Worker kit (view/preview/save) works for such names — justified
  5. Crewmate-update card Apply/Undo sends the name in the body — justified
  6. Card Undo for create/import, and the capabilities card, use the base64url route — justified
  7. Card hook treats a base64url route as its path-form route (step checks, memory line, guards) — justified
  8. Crewmate-update undo guard also arms on body-form PUT /api/agents — justified
  9. A malformed base64url segment gets 400 name_segment_invalid — justified
  10. Names containing !'()* now use base64url on these routes, but the dashboard Save keeps its old rule — symptom-level, two predicates

[FIRST-PRINCIPLES-REVIEWED] 6a10f8e

Description read

[DESCRIPTION-READ] 984e7856ec711203320e35d2893a810d1274f7fd8a4e58128234fc9d07df4a52

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 6a10f8ec4f12e9e0f09e35eaf7ffddce127e4189 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 6a10f8e

Verdict parsed from the review's SHA-scoped output markers for commit 6a10f8ec4f12e9e0f09e35eaf7ffddce127e4189.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 6a10f8ec4f12e9e0f09e35eaf7ffddce127e4189 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Hold at 6a10f8e.

This PR targets fix/agent-name-space-502 (stacked on #19981), not main, and it adds ten new /api/agents/b64/{name_b64} routes, which are reserved for human review. I found no defect: each twin reuses its path-form handler, so the owner gate runs first, and a non-canonical segment gets 400 name_segment_invalid (

app.router.add_delete("/api/agents/b64/{name_b64}", handlers.api_kirocrew_agent_delete)
).

What would clear it:

AI notes I judged non-blocking: the empty-name snapshot lookup before the 400 (nothing is written), the duplicated needs-encoding rule (both sides have unit tests), and the old Save predicate (the extra characters are not decoded by a proxy).

— crew-pr-reviewer (r144)

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[operator: bolichen97] Approving at 6a10f8e, reviewed against its base fix/agent-name-space-502.

Each base64url twin route is registered to the same handler as its path-form twin, and the owner gate runs before the name is decoded, so auth is identical. decode_agent_name rejects non-canonical, padded and non-UTF-8 segments with a 400. The twins are strictly deeper paths, so a crew literally named b64 keeps its path-form routes. Avatar files are keyed by a digest of the name, so a decoded name cannot reach the filesystem.

Non-blocking suggestions:

  • The !'()* parity between agentPath.ts and the server-side check is a two-language invariant. A shared fixture test would keep the two from drifting.
  • The agent_url_path imports in the change-card catalog modules could move to module scope.

This PR is stacked, so it lands after #19981.

AI-assisted, approved by bolichen97

@iamwhatever
iamwhatever merged commit fa43092 into fix/agent-name-space-502 Nov 4, 2026
30 of 41 checks passed
@iamwhatever
iamwhatever deleted the crew/bug-resolve/20083-agent-sibling-routes branch November 4, 2026 16:44
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 4, 2026
CrysisDeu added a commit that referenced this pull request Nov 4, 2026
…th (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
CrysisDeu added a commit that referenced this pull request Nov 4, 2026
…th (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
CrysisDeu added a commit that referenced this pull request Nov 4, 2026
…th (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
CrysisDeu added a commit that referenced this pull request Nov 4, 2026
…th (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
CrysisDeu added a commit that referenced this pull request Nov 4, 2026
…th (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
CrysisDeu added a commit that referenced this pull request Nov 5, 2026
…th (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
CrysisDeu added a commit that referenced this pull request Nov 6, 2026
…th (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
CrysisDeu added a commit that referenced this pull request Nov 7, 2026
…th (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
iamwhatever pushed a commit that referenced this pull request Nov 7, 2026
* fix(agents): send proxy-unsafe crew names in the request body

Fixes #19976

When a crew's config.json key contains a space (e.g. 'My Agent'), saving
from the dashboard editor calls PUT /api/agents/My%20Agent. A reverse
proxy that normalises percent-encoded paths decodes %20 to a literal
space, which is the HTTP request-line delimiter and causes a 502.

Fix: add PUT /api/agents (no path variable) that reads the crew name
from a 'name' field in the JSON body. The frontend uses this body-form
route automatically when encodeURIComponent(name) !== name, so a
space-containing key is never placed in a URL path segment a proxy can
misinterpret. The existing PUT /api/agents/{name} is unchanged for
slug-keyed agents.

The api_kirocrew_agent_update handler now serves both routes: it reads
the name from the URL path when present, or from the request body when
the path-variable route is not matched. The body name is used verbatim
(never stripped) so a stored key that differs only by edge whitespace is
not silently overwritten. Both forms share all update logic including
_require_owner, so auth and owner checks are identical.

change_card_catalog: add PUT /api/agents to HOOKED_ROUTES and
describe_manual_change so memory events are recorded for body-form
saves the same way they are for path-form saves.

Security: test_agents_endpoints_owner_auth.py already walks all routes
and verifies owner-gating; PUT /api/agents is added to its floor set.
test_agent_update_body_form.py pins auth parity between both routes.

* docs: add PUT /api/agents body-form route to crew-mode, learn-cron-dashboard, and feature map; update Pattern harvest and #20083 action

* fix(agents): keep proxy-unsafe crew names out of every agent route path (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>

---------

Co-authored-by: Zezhen Xu <zezhexu@amazon.com>
buluoray added a commit that referenced this pull request Nov 8, 2026
* fix(agents): send proxy-unsafe crew names in the request body

Fixes #19976

When a crew's config.json key contains a space (e.g. 'My Agent'), saving
from the dashboard editor calls PUT /api/agents/My%20Agent. A reverse
proxy that normalises percent-encoded paths decodes %20 to a literal
space, which is the HTTP request-line delimiter and causes a 502.

Fix: add PUT /api/agents (no path variable) that reads the crew name
from a 'name' field in the JSON body. The frontend uses this body-form
route automatically when encodeURIComponent(name) !== name, so a
space-containing key is never placed in a URL path segment a proxy can
misinterpret. The existing PUT /api/agents/{name} is unchanged for
slug-keyed agents.

The api_kirocrew_agent_update handler now serves both routes: it reads
the name from the URL path when present, or from the request body when
the path-variable route is not matched. The body name is used verbatim
(never stripped) so a stored key that differs only by edge whitespace is
not silently overwritten. Both forms share all update logic including
_require_owner, so auth and owner checks are identical.

change_card_catalog: add PUT /api/agents to HOOKED_ROUTES and
describe_manual_change so memory events are recorded for body-form
saves the same way they are for path-form saves.

Security: test_agents_endpoints_owner_auth.py already walks all routes
and verifies owner-gating; PUT /api/agents is added to its floor set.
test_agent_update_body_form.py pins auth parity between both routes.

* docs: add PUT /api/agents body-form route to crew-mode, learn-cron-dashboard, and feature map; update Pattern harvest and #20083 action

* fix(agents): keep proxy-unsafe crew names out of every agent route path (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

---------

(cherry picked from commit 4d0ae46)

Originally authored on main by Zezhen Xu (CrysisDeu); authored here with the public identity because the commit guard accepts only that identity.
buluoray added a commit that referenced this pull request Nov 8, 2026
* fix(agents): send proxy-unsafe crew names in the request body

Fixes #19976

When a crew's config.json key contains a space (e.g. 'My Agent'), saving
from the dashboard editor calls PUT /api/agents/My%20Agent. A reverse
proxy that normalises percent-encoded paths decodes %20 to a literal
space, which is the HTTP request-line delimiter and causes a 502.

Fix: add PUT /api/agents (no path variable) that reads the crew name
from a 'name' field in the JSON body. The frontend uses this body-form
route automatically when encodeURIComponent(name) !== name, so a
space-containing key is never placed in a URL path segment a proxy can
misinterpret. The existing PUT /api/agents/{name} is unchanged for
slug-keyed agents.

The api_kirocrew_agent_update handler now serves both routes: it reads
the name from the URL path when present, or from the request body when
the path-variable route is not matched. The body name is used verbatim
(never stripped) so a stored key that differs only by edge whitespace is
not silently overwritten. Both forms share all update logic including
_require_owner, so auth and owner checks are identical.

change_card_catalog: add PUT /api/agents to HOOKED_ROUTES and
describe_manual_change so memory events are recorded for body-form
saves the same way they are for path-form saves.

Security: test_agents_endpoints_owner_auth.py already walks all routes
and verifies owner-gating; PUT /api/agents is added to its floor set.
test_agent_update_body_form.py pins auth parity between both routes.

* docs: add PUT /api/agents body-form route to crew-mode, learn-cron-dashboard, and feature map; update Pattern harvest and #20083 action

* fix(agents): keep proxy-unsafe crew names out of every agent route path (#28628)

Every crew route that names the crew in its URL path also answers under
/api/agents/b64/{name_b64}..., an unpadded base64url segment, so a
path-normalising proxy has no %20 to decode into a bare space (502).
The twins reach the same handlers behind the same owner gate. The
dashboard (delete, avatar upload and image, capabilities, worker kit)
and change-card Apply/Undo steps use the twin or the body-form PUT for
such names; the card hook reads a twin as its path-form route.

Fixes #20083

---------

(cherry picked from commit 4d0ae46)

Originally authored on main by Zezhen Xu (CrysisDeu); authored here with the public identity because the commit guard accepts only that identity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants