Repository navigation
fix(spawn): guard resolveSpawnIdentity against non-uuid names #1628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2334,6 +2334,12 @@ export async function resolveSpawnIdentity( | |
| isAliveFn: (agent: { id: string; paneId: string }) => Promise<boolean> = (agent) => | ||
| executorRegistry.resolveWorkerLivenessByTransport(agent), | ||
| ): Promise<SpawnIdentity> { | ||
| // Migration 061 + PR #1627: agents.id is UUID. Non-UUID names cannot match | ||
| // by id; skip the canonical-lookup query and return a fresh canonical with | ||
| // a generated UUID workerId. Keeps role-based dispatch working post-061. | ||
| if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(name)) { | ||
| return { kind: 'canonical', workerId: uuidFactory(), sessionUuid: uuidFactory() }; | ||
|
Comment on lines
+2340
to
+2341
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Returning early for any non-UUID Useful? React with 👍 / 👎. |
||
| } | ||
| const { getConnection } = await import('../lib/db.js'); | ||
| const sql = await getConnection(); | ||
| // `agents.id` is the PRIMARY KEY (migrations/005_pg_state.sql), so the | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the existing
UUID_REGEXconstant (defined at line 2258) instead of duplicating the regex literal. This improves maintainability and ensures consistency across the module.Additionally, while this guard prevents crashes for role-based names (like "engineer"), the parallel spawn logic later in this function (line 2413) still constructs
workerIdas${name}-${shortId}. Ifagents.idis aUUIDtype in Postgres, those parallel IDs will still causeinvalid input syntax for type uuiderrors. You should consider updating the parallel ID generation to ensure it always produces a valid UUID.