Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Updates knowledge base and table services to detect/translate Postgres unique violations into new Frontend behavior is tweaked to surface these failures: React Query mutations no longer retry by default, key mutations show error toasts, and the toast/notification countdown ring is extracted/reused with toast auto-dismiss pausing on hover. Written by Cursor Bugbot for commit 5ca1d5b. 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" |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| ) | ||
| ) | ||
|
|
||
| logger.info(`Successfully restored workspace file: ${fileRecord.name}`) |
There was a problem hiding this comment.
Workspace file restore lacks race-condition protection unlike peers
Low Severity
restoreWorkspaceFile calls generateRestoreName and then performs the DB update non-atomically, without a transaction or retry loop. The analogous restoreTable and restoreKnowledgeBase functions both use FOR UPDATE locks inside transactions with retry loops for 23505 errors. While workspace files lack a unique index on names (so no DB error occurs), a concurrent upload or restore can claim the chosen name between the check and the update, silently producing duplicate display names.


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