refactor(core): Clean up workflow reviews backend (no-changelog) - #36907
Open
kgrhartlage wants to merge 1 commit into
Open
refactor(core): Clean up workflow reviews backend (no-changelog)#36907kgrhartlage wants to merge 1 commit into
kgrhartlage wants to merge 1 commit into
Conversation
Zero-risk cleanup, no behavior changes: - Delete the unused `setReviewers` and singular `findByRequestId` methods on the review author/reviewer repositories, plus the test that only covered `setReviewers`. - Merge the two identical description normalizers in the request service. - Rename `DbLock.WORKFLOW_REVIEW_REQUEST_CREATE` to `WORKFLOW_REVIEW_MUTATION` — it guards every review mutation, not just creation. The numeric value stays 1004, since that is the Postgres lock key. - Fix comments that referenced a removed endpoint and that claimed id order is insertion order (ids are nanoids). - Run `getRawAndEntities` and `getCount` sequentially in `findRequestsForWorkflow` instead of concurrently on one query builder. https://linear.app/n8n/issue/LIGO-1034 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
PR review overviewBased on ownership of the 15 changed files in this PR:
|
Contributor
Author
|
@cubic-dev-ai roast my PR |
Contributor
@kgrhartlage I have started the AI code review. It will take a few minutes to complete. |
Contributor
There was a problem hiding this comment.
No issues found across 15 files
Architecture diagram
sequenceDiagram
participant C as Client/Controller
participant S as WorkflowReviewRequestService
participant L as DbLockService
participant R as WorkflowReviewRequestRepository
participant DB as Postgres Database
Note over C,DB: Workflow Review Mutation Flow (Create, Decide, or Update)
C->>S: create() / decide() / updateVersion()
S->>L: CHANGED: withLockContext(WORKFLOW_REVIEW_MUTATION)
Note right of L: Lock key remains 1004 (PG Advisory Lock)
L->>DB: Acquire Advisory Lock (1004)
DB-->>L: Lock Acquired
rect rgb(240, 240, 240)
Note over S,DB: Inside Transaction Context
S->>R: findById(requestId, ctx)
R-->>S: current state
alt Request is Updatable
S->>S: NEW: normalizeDescription(description)
S->>R: saveRequest(updatedData, ctx)
R->>DB: UPDATE/INSERT
else Request Stale/Invalid
S-->>C: Throw NotFoundError / Conflict
end
end
L->>DB: Release Advisory Lock
S-->>C: RequestSummary
Note over C,DB: Workflow Search/List Flow
C->>R: findRequestsForWorkflow(options)
R->>R: Create QueryBuilder (qb)
rect rgb(230, 245, 255)
Note over R,DB: CHANGED: Sequential Execution (Prevents Builder Mutation Race)
R->>DB: qb.getRawAndEntities()
DB-->>R: entities + raw data
R->>DB: qb.getCount()
DB-->>R: total count
end
R-->>C: { entities, count }
Note over R,DB: NEW: Repository Cleanup
Note right of R: Deleted: setReviewers()<br/>Deleted: authorRepo.findByRequestId()<br/>Deleted: reviewerRepo.findByRequestId()
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
kgrhartlage
marked this pull request as ready for review
August 24, 2026 10:32
Contributor
There was a problem hiding this comment.
No issues found across 15 files
Architecture diagram
sequenceDiagram
participant C as Client/Controller
participant S as WorkflowReviewRequestService
participant L as DbLockService
participant R as WorkflowReviewRequestRepository
participant DB as Postgres Database
Note over C,DB: Workflow Review Mutation Flow (Create, Decide, or Update)
C->>S: create() / decide() / updateVersion()
S->>L: CHANGED: withLockContext(WORKFLOW_REVIEW_MUTATION)
Note right of L: Lock key remains 1004 (PG Advisory Lock)
L->>DB: Acquire Advisory Lock (1004)
DB-->>L: Lock Acquired
rect rgb(240, 240, 240)
Note over S,DB: Inside Transaction Context
S->>R: findById(requestId, ctx)
R-->>S: current state
alt Request is Updatable
S->>S: NEW: normalizeDescription(description)
S->>R: saveRequest(updatedData, ctx)
R->>DB: UPDATE/INSERT
else Request Stale/Invalid
S-->>C: Throw NotFoundError / Conflict
end
end
L->>DB: Release Advisory Lock
S-->>C: RequestSummary
Note over C,DB: Workflow Search/List Flow
C->>R: findRequestsForWorkflow(options)
R->>R: Create QueryBuilder (qb)
rect rgb(230, 245, 255)
Note over R,DB: CHANGED: Sequential Execution (Prevents Builder Mutation Race)
R->>DB: qb.getRawAndEntities()
DB-->>R: entities + raw data
R->>DB: qb.getCount()
DB-->>R: total count
end
R-->>C: { entities, count }
Note over R,DB: NEW: Repository Cleanup
Note right of R: Deleted: setReviewers()<br/>Deleted: authorRepo.findByRequestId()<br/>Deleted: reviewerRepo.findByRequestId()
kgrhartlage
commented
Aug 24, 2026
| ); | ||
| if (!current) { | ||
| throw new NotFoundError('Could not find review request'); | ||
| } = await this.dbLockService.withLockContext(DbLock.WORKFLOW_REVIEW_MUTATION, async (ctx) => { |
Contributor
Author
There was a problem hiding this comment.
the shorter enum name lets two withLockContext(...) callbacks fit on one line, so biome re-indents ~200 lines of those blocks. It's pure whitespace, there is no other change here
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
Zero-risk cleanup of the workflow reviews backend. No behavior changes.
setReviewersand the singularfindByRequestIdon the review author and reviewer repositories (@n8n/db) had no production callers. The dedicated test file forsetReviewersis deleted with it. The@n8n/dbpackage documents no compatibility policy for its public method surface, so nothing protects these. Note that the workflow repository keeps its ownfindByRequestId— that one is live.normalizeVersionDescriptionandnormalizeReviewDescriptioninworkflow-review-request.service.tshad the same body. They are now onenormalizeDescription.DbLock.WORKFLOW_REVIEW_REQUEST_CREATEbecomesWORKFLOW_REVIEW_MUTATION, because it guards every review mutation, not only creation. The numeric value stays1004— that value is the actual Postgres advisory lock key.status batchendpoint that no longer exists. Two comments claimed that rows arrive in insertion order because the query sorts by id. Ids are nanoids, so id order is not insertion order.findRequestsForWorkflowrangetRawAndEntities()andgetCount()in aPromise.allon one builder. Each call mutates the builder while it runs. They now run in sequence.The diff on
workflow-review-request.service.tslooks larger than the change is. The shorter enum name lets twowithLockContext(...)callbacks fit on one line, so Biome re-indents those two blocks. That part of the diff is whitespace only, andformat:checkrequires it.How to test
This is a refactor, so the tests are the test. No env vars, license, or feature flag are needed to verify it.
Results locally:
@n8n/dbbuilds and lints clean with 552 tests passing;packages/clitypechecks clean with 242 unit tests and 247 integration tests passing.To confirm the lock rename is name-only, check that the enum member still reads
WORKFLOW_REVIEW_MUTATION = 1004inpackages/@n8n/db/src/services/db-lock.service.ts. A changed value would move the advisory lock key and let two review mutations run at once on Postgres.Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/LIGO-1034
Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)🤖 PR Summary generated by AI