Enforce name uniqueness#3679
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Introduces standardized conflict detection ( Improves client feedback by disabling React Query mutation retries, adding toast errors on mutation failures (KB update, table rename, file rename), and refactoring the notification countdown ring into a shared Written by Cursor Bugbot for commit b564d0c. This will update automatically on new commits. Configure here. |
Greptile SummaryThis PR enforces name uniqueness for knowledge bases, tables, and workspace files — both preventing duplicate creation/renaming and gracefully resolving conflicts when restoring archived entities by auto-generating a unique Key changes:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User renames / creates entity] --> B{Entity type?}
B -->|Knowledge Base| C[SELECT duplicate check\nby workspaceId + name]
C -->|Duplicate found| D[throw KnowledgeBaseConflictError]
C -->|No duplicate| E[INSERT / UPDATE KB]
D --> F[API returns 409]
F --> G[useUpdateKnowledgeBase\nonError → toast.error]
B -->|Table| H[UPDATE userTableDefinitions\ncatch DB error 23505]
H -->|Caught 23505| I[throw TableConflictError]
H -->|Success| J[Return updated table]
I --> K[API returns 409]
K --> L[useRenameTable\nonError → toast.error]
B -->|Workspace File| M[PATCH /files/:id\ncatch non-ok response]
M -->|Error| N[useRenameWorkspaceFile\nonError → toast.error]
subgraph Restore Flow
O[Restore archived entity] --> P[generateRestoreName]
P --> Q{originalName free?}
Q -->|Yes| R[Use original name]
Q -->|No| S{name_restored free?}
S -->|Yes| T[Use name_restored]
S -->|No| U[Use name_restored_hex\n⚠ not verified unique]
R & T & U --> V[UPDATE set deletedAt=null\n+ new name]
end
Last reviewed commit: "Fix lint" |
| strokeLinecap='round' | ||
| strokeDasharray={RING_CIRCUMFERENCE} | ||
| style={{ | ||
| animation: `notification-countdown ${duration}ms linear forwards`, |
There was a problem hiding this comment.
Shared CountdownRing depends on external CSS keyframe
Low Severity
The CountdownRing component is now exported from the shared emcn component library, but it references the CSS animation name notification-countdown which is only defined in apps/sim/app/_styles/globals.css. This creates a hidden coupling — any consumer of CountdownRing outside the app context (or if the keyframe is renamed) would get a static, non-animating ring with no indication of failure. A self-contained component would define its own keyframe or accept it as a prop.
Additional Locations (1)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


Summary
Going forward, resources should have unique names. Added validation and error throwing on duplicate names and also added the unique name constraint to knowledge bases.
Resources with duplicate names would trigger a toast popup saying that the name is not unique.
Type of Change
Testing
Validated migration, validated that creating resources works correctly and throws error.
Checklist
Screenshots/Videos