Fix organization and project name validation - #2422
Conversation
7bf6f5d to
ddbbe3b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 366626430b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ddbbe3b to
2ea92b3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce4569e6fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var changed = changes.GetEntity(); | ||
| if (!await IsOrganizationNameAvailableInternalAsync(changed.Name, httpContext)) | ||
| return Result.BadRequest("A organization with this name already exists."); | ||
| if (changes.ContainsChangedProperty(p => p.Name) && String.IsNullOrEmpty(changes.GetEntity().Name)) |
There was a problem hiding this comment.
Reject whitespace-only organization names
BLOCKER: When an organization PATCH or PUT supplies a name containing only spaces, String.IsNullOrEmpty accepts it and the handler persists a blank display name. The previous availability check used String.IsNullOrWhiteSpace, so this regresses the existing required-name contract; use the whitespace-aware check here as well.
AGENTS.md reference: AGENTS.md:L67-L67
Useful? React with 👍 / 👎.
Summary
projectId201means unavailable,204means available, and duplicate project mutations remain400 Bad RequestRoot cause
Organization create/update enforced an obsolete uniqueness rule. Update validation also searched every visible organization without excluding the organization being updated, so an explicit same-name PATCH collided with itself.
Project validation had the same self-collision bug. Its unscoped route could also search across organizations even though the current UIs operate in an organization context.
The extra GET after a failed Svelte PATCH came from
onErrorinvalidating unchanged cached state. Successful server changes still use the existing WebSocket invalidation flow; this PR does not change WebSocket handling or add local echo state.API behavior
GET /api/v2/organizations/{organizationId}/projects/check-nameaccepts optionalprojectId201/204meanings are unchanged; only their reversed OpenAPI descriptions were corrected400 Bad RequestVerification
projectId, 201, no PATCHprojectId, 204, PATCH 200Breaking changes
The obsolete unscoped
GET /api/v2/projects/check-nameandGET /api/v2/organizations/check-nameroutes are removed. The organization-scoped project check-name route remains available.