Repository navigation
feat(coderd): conditional writes for saved workflows (fork-workflows) - #394
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f59537e22
ℹ️ 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".
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
PATCH and DELETE for saved workflows (user and organization tiers) accept an optional expect_id query parameter. When present, the write lands only when the stored workflow still has that id, and a mismatch answers 409 Conflict with nothing changed. Without the parameter behavior is unchanged. The check lives in the write queries themselves, so the dbauthz wrappers authorize the caller before any id comparison, no read leaks a hidden workflow's id, and the check is atomic with the write. A no-rows conditional write re-reads with the caller's authorization to tell 404 from 409. codersdk client update and delete methods take an optional ForkSavedWorkflowWriteParams with ExpectID.
9f59537 to
0b86d4b
Compare
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merged main (49f454e) to clear the not-behind gate. @codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merged main (c631d81) and regenerated the apidoc enum ordering the sync moved. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2632cd0d94
ℹ️ 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".
…fetch miss Codex review of 2632cd0 found that the organization conditional write wrappers fetch the row before Authorize runs, so a sql.ErrNoRows from the fetch reached okAfterConditionalWrite as if the authorized write had dropped every row, and the conflict check then read the row as the system. A caller whose conditional write raced with a delete and a recreate of a hidden workflow could get a 409 that proves the workflow exists. Mark a fetch-phase miss in fork_forkdb.go and let the handler skip its system probe for it, which keeps the pre-existing 404.
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7cf24fcad
ℹ️ 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".
Replied above:
|
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b02d9bfb1
ℹ️ 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".
…rite and reject a malformed query
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merged origin/main (080e195, the upstream sync from #398) into the branch after 1b71293. No code changes. All checks re-verified locally. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e85f319162
ℹ️ 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".
|
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merged at head Gates on this exact head:
Tests I ran on
Review notes:
Not exercised: a running server with two users racing a delete and recreate, and the hidden-replacement probe path, which has no dedicated test. |
Part of #392. The site client part waits for #387 and lands separately.
What
The saved workflow PATCH and DELETE endpoints (user and organization tiers) accept an optional
expect_idquery parameter. When present, the write lands only when the stored workflow still has that id. A mismatch answers 409 Conflict with nothing changed and no stored id in the response. Without the parameter, behavior is unchanged from main.How
The condition lives inside the four forkdb write queries:
so:
user_skill:updatewithout read) can still send a conditional write.On
sql.ErrNoRowswithexpect_id, the handler re-reads once to tell 404 (row gone) from 409 (row exists with a different id). Denials probe with the caller's own authorization, so a caller who cannot read a hidden workflow keeps getting 404.Tests
TestForkSavedWorkflowConditionalWrites(18 subtests, user and organization tiers): mismatch 409 with no change, match succeeds, no-parameter old behavior, invalid id 400, missing workflow 404, update-only scope succeeds on match, delete-only scope gets 409 on mismatch, hidden workflow stays 404 on denial and on mismatch for a non-reader.Negative control: neutralizing the SQL clause to a tautology makes
PatchMismatchConflictsfail (update succeeded, expected conflict), and removing the clause outright fails the build because the generated params struct losesExpectID. Both restored afterwards.Verification
go build ./...passes.go test ./coderd/ ./coderd/database/forkdb/ ./coderd/database/dbauthz/ ./coderd/x/chatd/ ./codersdk/passes. One pre-existing flake,TestForkPluginPackEnablement, fails under full-suite load with context deadline exceeded and passes in isolation and on the base commit.bash .github/fork/check-apidoc.shexits 0.golangci-lint run ./coderd/...reports no findings in the touched files. The baseline has pre-existing findings elsewhere.Part of #392 (backend part; the site client follows in a separate PR once #387 merges).