Skip to content

Commit 8d7ebee

Browse files
d-csclaude
andcommitted
fix(webapp): use derived friendlyId for parent metadata fan-out on buffered runs
Devin follow-up on PR #3756. The parent branch of the metadata route's fan-out passed `bufferedEntry.parentTaskRunId` (an internal cuid) where the rest of the route works in friendlyIds. `updateMetadataService.call` does auto-detect internal vs friendly via `runId.startsWith("run_")` so the lookup succeeded for the common case (parent materialised in PG), but the inconsistency surfaced as soon as `readFallback.server.ts` was fixed to derive `parentTaskRunFriendlyId` / `rootTaskRunFriendlyId` from the snapshot's internal IDs via `internalRunIdToFriendlyId` — at that point the parent path was the only consumer still passing the internal id. Switch the parent route to `bufferedEntry.parentTaskRunFriendlyId ?? runId`, mirroring the root path's shape. The `?? runId` matches the PG service's own self-fallback (`taskRun.parentTaskRun?.id ?? taskRun.id`) so a top-level run's parent ops land on itself rather than being silently dropped. Stale comment block about "parentTaskRunId is an internal id" removed — both fields are now friendlyIds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 44da36e commit 8d7ebee

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

apps/webapp/app/routes/api.v1.runs.$runId.metadata.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,22 @@ const { action } = createActionApiRoute(
210210
organizationId: env.organizationId,
211211
});
212212
if (bufferedEntry) {
213+
// Both parent and root use the friendlyIds derived in
214+
// `readFallback.server.ts` via `internalRunIdToFriendlyId` from the
215+
// internal IDs the engine snapshot carries (`parentTaskRunId` /
216+
// `rootTaskRunId`). The PG-side `UpdateMetadataService` would
217+
// route to `taskRun.parentTaskRun?.id ?? taskRun.id` and
218+
// `taskRun.rootTaskRun?.id ?? taskRun.id` respectively — i.e. fall
219+
// back to the run itself when there's no parent / root. Mirror
220+
// that self-fallback with `?? runId` so a top-level run's
221+
// parent/root ops land on itself (matching PG semantics) instead
222+
// of being silently dropped.
213223
await Promise.all([
214-
routeOperationsToRun(bufferedEntry.parentTaskRunId, body.parentOperations, env),
215-
// The PG service routes rootOperations to
216-
// `taskRun.rootTaskRun?.id ?? taskRun.id` — the actual root, not
217-
// the parent. The snapshot carries the root's *friendlyId*
218-
// (parentTaskRunId is an internal id; root is friendlyId because
219-
// it's what the engine passes through). Use it; if absent,
220-
// route to the run itself (matches PG's self-fallback) rather
221-
// than misrouting to the parent for grandchild → child → root
222-
// hierarchies.
224+
routeOperationsToRun(
225+
bufferedEntry.parentTaskRunFriendlyId ?? runId,
226+
body.parentOperations,
227+
env,
228+
),
223229
routeOperationsToRun(
224230
bufferedEntry.rootTaskRunFriendlyId ?? runId,
225231
body.rootOperations,

0 commit comments

Comments
 (0)