Repository navigation
fix(custom-tools): skip title conflicts when persisting inline tools from a workflow save - #9198
Merged
Merged
Conversation
…from a workflow save
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Contributor
[Medium impact] The PR appears safe to merge; no blocking issues were found. SummaryWorkflow saves and imports now skip inserts whose titles already exist, without overwriting those tools or rolling back other inserts.
Reviews (2) · Last reviewed commit: "fix(custom-tools): count skipped titles ..." · Reviewed by Greptile |
Collaborator
Author
|
@greptile |
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
toolId. The first save inserts a workspace row under a generated id that is never written back to the block, so every later save of the same workflow re-offers the tool with no id, hits the workspace title-uniqueness guard on the row that same flow created, and throws.upsertCustomToolsruns the batch in one transaction, so every other tool in that save is rolled back too, and the save logs "Some custom tools failed to persist".operations.tsinto a shared loop with a title-conflict policy.upsertCustomToolskeeps its signature and runs it with'error'. The newupsertCustomToolsSkippingTakenTitlesruns it with'skip': the insert usesON CONFLICT (workspace_id, title) DO NOTHING, so a title that already exists (including one a concurrent save just committed) is left untouched and the rest of the batch persists. It returns the skipped titles.persistCustomToolsToDatabase(the post-commit step of the shared workflow state replace and of workflow import) now calls the skipping variant, andsavedcounts only the tools actually written.updatedAt. When it is not the same tool, it is an unrelated library tool that must not be overwritten. Both cases come down to leaving the row alone, so skip is the smaller change. The block still runs from its inline definition either way.POST /api/tools/custom, the v2 create use case) still callupsertCustomTools, so a duplicate title still throws and the whole batch rolls back (500 on the internal route, 409 on v2, as before). Id-resolved updates and legacy-tool updates are untouched. The only persistence change is that a conflicting title no longer fails the batch.Type of Change
Testing
custom-tools-persistence.integration.tsagainst real Postgres: saving the same graph twice (inline tool withouttoolId) returns no errors on the second save, persists the new tool next to it, and reports only that tool as saved; two concurrent saves of the same new tool both succeed and leave one row; an existing workspace tool with the same title keeps its code;upsertCustomToolswithout the option still rejects a duplicate title and rolls back the rest of its batch.Checklist
test-auditauthoring gate)