Skip to content

Prevent duplicate workspace creation on retried submissions - #574

Open
yuanweize wants to merge 1 commit into
trypostit:mainfrom
yuanweize:fix/workspace-creation-idempotency
Open

yuanweize wants to merge 1 commit into
trypostit:mainfrom
yuanweize:fix/workspace-creation-idempotency

Conversation

@yuanweize

@yuanweize yuanweize commented Dec 3, 2026 •

Copy link
Copy Markdown

Problem

On a self-hosted instance, six same-name workspaces were created within 15 seconds. The creation endpoint currently serializes requests by locking the account, but each accepted POST still creates a new workspace. The loading button prevents some duplicate clicks, not retries or repeated HTTP submissions. The exact original trigger was not established.

Proposed fix

  • Generate a creation-request UUID when rendering the workspace creation form, retain it in the Inertia form and ignore submit events while a request is processing.
  • Validate the optional UUID and check it within the existing account transaction, before the workspace-count limit check. A replay for the same account and user returns the usual success redirect without creating or switching to another workspace.
  • Persist the identifier with a scoped unique index. Existing workspaces and older name-only submissions remain supported. Separate requests can still intentionally create workspaces with the same name; no existing data is deduplicated or deleted.

Verification

  • Added feature coverage for identical request replay, independent requests sharing a name, cross-account isolation and malformed UUIDs, and asserted the form includes a request identifier.
  • PHP syntax checks passed for all six changed PHP files; git diff --check passed.
  • Full Pest, Pint, database migration and browser tests have not been run locally: the available production image lacks development test tools. The upstream Tests and linter workflows currently require action and have not started. I also attempted to run the same workflows in an isolated branch of my fork, but GitHub did not register the workflows. Could a maintainer approve the upstream CI runs when convenient? PostgreSQL/MySQL and browser verification remain pending. No production deployment of this patch has been performed.

Use a form-specific request UUID and the existing per-account transaction lock to make repeated creates idempotent without imposing unique workspace names. Add a scoped unique constraint, input validation, and regression coverage.
@yuanweize
yuanweize marked this pull request as ready for review December 4, 2026 01:23
Copilot AI balanced review requested due to automatic review settings December 4, 2026 01:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
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