Skip to content

fix(git): return 409 when GitHub repo name already exists - #64

Merged
dviejokfs merged 3 commits into
mainfrom
fix/git-repo-already-exists-409
Apr 26, 2026
Merged

dviejokfs merged 3 commits into
mainfrom
fix/git-repo-already-exists-409

Conversation

@dviejokfs

Copy link
Copy Markdown
Contributor

Summary

  • Detect GitHub's 422 name already exists response and surface it as a typed GitProviderError::RepositoryAlreadyExists { name } variant.
  • Map the new variant to 409 Conflict with a clear detail message, so the frontend can show actionable feedback instead of a generic 500.
  • Stop double-wrapping GitProviderManagerError::ProviderError — forward the typed Problem directly.
  • Frontend: rewrite extractProblemDetails to (1) use the correct RFC 7807 field name type (not type_url), (2) unwrap body / error / data envelopes used by hey-api's openapi-ts client, and (3) gate detection on a proper type guard so unrelated thrown objects are not misidentified as ProblemDetails.

Files

  • crates/temps-git/src/services/git_provider.rs — new error variant
  • crates/temps-git/src/services/github_provider.rs — parse 422 body, detect name field "already exists"
  • crates/temps-git/src/handlers/base.rs — map variant to 409, drop redundant wrapping
  • crates/temps-projects/src/handlers/handlers.rs — propagate typed Problem instead of converting to 500
  • web/src/utils/errorHandling.ts — fix RFC 7807 field name and envelope unwrapping

Test plan

  • Create a repository through the project flow with a name that already exists on the linked GitHub account → expect a 409 with a "Repository Already Exists" toast/banner instead of a 500.
  • Create a repository with a fresh name → expect success unchanged.
  • Hit any other ProblemDetails-returning endpoint and confirm the frontend still extracts title / detail correctly through both the bare and body-nested shapes.

Detect GitHub's 422 "name already exists" response when creating a
repository and surface it as a typed `GitProviderError::RepositoryAlreadyExists`
variant. The handler maps this to a 409 Conflict with an actionable detail
message instead of flattening it to a generic 500.

Also fix the frontend ProblemDetails extractor: it was looking for the
nonexistent `type_url` field instead of RFC 7807's `type`, and it didn't
unwrap envelopes used by hey-api's openapi-ts client (`body`, `error`,
`data`). The new version uses a proper type guard and recognizes any
shape that carries a `title` plus one canonical RFC 7807 field.
Document the 409-on-duplicate-GitHub-repo-name fix and the
ProblemDetails extraction rewrite for downstream release notes.
Move the PR #64 changelog from tmp/ into the actual CHANGELOG.md
under [Unreleased] -> Fixed, so the changelog-check CI passes and
the entry shows up in the next release notes.
@dviejokfs
dviejokfs merged commit 287d24d into main Apr 26, 2026
6 checks passed
@dviejokfs
dviejokfs deleted the fix/git-repo-already-exists-409 branch July 1, 2026 00:08
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.

1 participant