Skip to content

fix(dispatch): report a taken app id instead of a 500 - #5629

Merged
samijaber merged 1 commit into
mainfrom
fix/app-id-taken-result
Sep 23, 2026
Merged

samijaber merged 1 commit into
mainfrom
fix/app-id-taken-result

Conversation

@samijaber

Copy link
Copy Markdown
Contributor

What happened

Creating a workspace app whose id is already taken returned {"error":"Internal server error"} in the create-app popover, with no indication of the real cause.

startWorkspaceAppCreation checks for an id collision in two places, and neither call was inside a try:

  • assertPendingWorkspaceAppCreationAvailable — a pending creation owned by another member
  • reservePendingWorkspaceApp — a registered app, or a pending creation owned by anyone, including the caller

Each builds a message that names the conflict and, for an in-flight creation, who holds it. Both threw, so the action route flattened them to a generic 500 and that message never reached the UI or chat.

The second gate is what users actually hit: start an app, have it stall in pending, retry the same prompt, get "Internal server error" with nothing to act on.

Changes

  • WorkspaceAppIdTakenError carries appId, conflict ("registered" | "pending") and owner. Both collision paths throw it.
  • startWorkspaceAppCreation converts only that error into a new app-id-taken result mode. Registry and storage failures from the same helpers keep propagating — an unreadable app registry stays a fault, rather than being reported as a name the caller can simply change.
  • workspace-template-card fell through to toast.success(labels.remixSuccess) for any mode it did not recognize, so this result would have rendered a green "remixed" toast on a failure. It now reports it as an error.
  • simple-agents-panel's result union and the start-workspace-app-creation agent instructions in integrations.ts both learn the new mode.

The create-app popover and NewWorkspaceAppFlow needed no change: their fallback branch already renders result.message, which is exactly what was being thrown away.

This follows the repo's own rule that a failure coerced into a value callers cannot distinguish from success is a bug — the template card's silent-success default was that shape.

Testing

  • app-creation-store.spec.ts: 63 passed. The two cross-member collision tests now assert the typed result instead of a throw, plus a new test covering the same-owner in-flight case that produced the original 500.
  • Full packages/dispatch suite: 737 passed, 0 failed.
  • oxfmt run on all modified files; changeset added.

Four spec files in the full run fail to load with Failed to resolve import "qrcode.react", and 13 tsc errors remain — all from stale dependencies in my local checkout (@agent-native/core will not build: missing @better-auth/scim). None are in the files this PR touches, and none are test failures.

startWorkspaceAppCreation checked for an app id collision in two places —
the cross-member pending guard and the reservation itself — and neither
call was inside a try. Both threw, so the message each one built, naming
the conflict and the owner holding it, was replaced by a generic
"Internal server error" in the create-app UI and in chat.

Both paths now throw WorkspaceAppIdTakenError, and the caller converts
only that error into a typed `app-id-taken` result carrying `conflict`
("registered" or "pending") and `owner`. Registry and storage failures
from the same helpers keep propagating, so an unreadable registry is
still a fault rather than a name the caller is told to change.

workspace-template-card treated every unrecognized mode as success and
would have toasted a green "remixed" for this one; it now reports it as
an error.
@samijaber
samijaber requested review from a team and sidmohanty11 and removed request for a team September 22, 2026 16:08
@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Here's a visual recap of what changed:

Visual recap

Open the full interactive recap

@github-actions
github-actions Bot temporarily deployed to pr-5629-dispatch September 22, 2026 16:12 Destroyed
@github-actions
github-actions Bot temporarily deployed to pr-5629-design September 22, 2026 16:13 Destroyed

@builder-io-integration builder-io-integration Bot 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.

Builder reviewed your changes — looks good ✅

Review Details

Code Review Summary

PR #5629 changes workspace app creation so registered and pending app-ID collisions become a typed app-id-taken result instead of an unhandled exception that is flattened to a generic 500. The implementation introduces WorkspaceAppIdTakenError, converts only that error at both collision gates, preserves registry/storage failures as real faults, extends the result union and agent instructions, and makes the template-card path show an error toast rather than falling through to success. The approach is sound and keeps the collision-specific recovery information (appId, conflict type, and pending owner) available to callers. Tests cover cross-member and same-owner pending collisions, and both independent code-review passes found no actionable issues. Risk assessment: Standard, because this changes shared dispatch business logic and several UI result consumers, but does not alter authentication, payments, schema, or destructive mutation behavior.

Findings

No confirmed actionable findings.

✅ Good coverage of the two previously unhandled collision paths.
✅ Catch blocks are deliberately narrow, so unreadable registry/storage state is not misreported as a user-fixable name conflict.
✅ The template-card unknown-result success fallthrough is corrected for the new mode.

🧪 Browser testing: Attempted after review; 0/11 cases could be verified because browser executor sessions did not expose Chrome navigation/snapshot/click/screenshot tools. The dev server was healthy, and this is an infrastructure limitation rather than an application failure.

@samijaber
samijaber enabled auto-merge (squash) September 22, 2026 19:00
@samijaber
samijaber merged commit 5ed3eb0 into main Sep 23, 2026
51 checks passed
@samijaber
samijaber deleted the fix/app-id-taken-result branch September 23, 2026 00:02

This branch was successfully deployed

No deployments
pr-5629-design 8d68156d Deployed Sep 22, 2026 by github-actions[bot]
pr-5629-dispatch 8d68156d Deployed Sep 22, 2026 by github-actions[bot]
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.

2 participants