-
Notifications
You must be signed in to change notification settings - Fork 18
fix: crud operations on var sets trigger reconciliations #912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import { | |
| takeFirstOrNull, | ||
| } from "@ctrlplane/db"; | ||
| import { db } from "@ctrlplane/db/client"; | ||
| import { enqueueAllReleaseTargetsDesiredVersion } from "@ctrlplane/db/reconcilers"; | ||
| import * as schema from "@ctrlplane/db/schema"; | ||
|
|
||
| const listVariableSets: AsyncTypedHandler< | ||
|
|
@@ -87,6 +88,8 @@ const createVariableSet: AsyncTypedHandler< | |
| return vs; | ||
| }); | ||
|
|
||
| enqueueAllReleaseTargetsDesiredVersion(db, workspaceId); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n apps/api/src/routes/v1/workspaces/variable-sets.ts | head -220Repository: ctrlplanedev/ctrlplane Length of output: 7287 🏁 Script executed: rg -A 5 -B 5 "logger\." apps/api/src/routes/v1/workspaces/variable-sets.tsRepository: ctrlplanedev/ctrlplane Length of output: 48 🏁 Script executed: rg "logger" apps/api/src/routes/ -t ts --max-count 5 | head -20Repository: ctrlplanedev/ctrlplane Length of output: 753 🏁 Script executed: grep -r "import.*logger" apps/api/src/routes/tfe/ --include="*.ts" | head -5Repository: ctrlplanedev/ctrlplane Length of output: 230 🏁 Script executed: sed -n '110,120p' apps/api/src/routes/tfe/run_notification.tsRepository: ctrlplanedev/ctrlplane Length of output: 314 🏁 Script executed: sed -n '1,30p' apps/api/src/routes/tfe/run_notification.tsRepository: ctrlplanedev/ctrlplane Length of output: 1281 🏁 Script executed: sed -n '100,125p' apps/api/src/routes/tfe/run_notification.tsRepository: ctrlplanedev/ctrlplane Length of output: 573 🏁 Script executed: rg "void enqueueAllReleaseTargetsDesiredVersion" apps/api/src/routes/ -A 1Repository: ctrlplanedev/ctrlplane Length of output: 48 🏁 Script executed: rg "void.*catch" apps/api/src/routes/ -B 1 -A 1 | head -30Repository: ctrlplanedev/ctrlplane Length of output: 48 🏁 Script executed: rg "enqueueAllReleaseTargetsDesiredVersion" apps/api/src/routes/v1/workspaces/variable-sets.ts -B 2 -A 2Repository: ctrlplanedev/ctrlplane Length of output: 626 🏁 Script executed: sed -n '138,176p' apps/api/src/routes/v1/workspaces/variable-sets.tsRepository: ctrlplanedev/ctrlplane Length of output: 1054 🏁 Script executed: rg -B 5 -A 5 "if.*workspaceId.*null" apps/api/src/routes/tfe/run_notification.tsRepository: ctrlplanedev/ctrlplane Length of output: 314 Add explicit fire-and-forget handling with error logging for all three enqueue calls. The floating promises at lines 91, 169, and 196 can cause unhandled rejections if the queue write fails after the response is sent. These should use the pattern Line 169 requires special attention: this call sits inside the You'll also need to import logger: 🤖 Prompt for AI Agents |
||
|
|
||
| res.status(201).json(created); | ||
| }; | ||
|
|
||
|
|
@@ -167,6 +170,7 @@ const updateVariableSet: AsyncTypedHandler< | |
| }); | ||
|
|
||
| if (updated == null) throw new NotFoundError("Variable set not found"); | ||
| enqueueAllReleaseTargetsDesiredVersion(db, workspaceId); | ||
| res.status(202).json(updated); | ||
| }; | ||
|
|
||
|
|
@@ -187,6 +191,9 @@ const deleteVariableSet: AsyncTypedHandler< | |
| .then(takeFirstOrNull); | ||
|
|
||
| if (deleted == null) throw new NotFoundError("Variable set not found"); | ||
|
|
||
| enqueueAllReleaseTargetsDesiredVersion(db, workspaceId); | ||
|
|
||
| res.status(202).json(deleted); | ||
|
Comment on lines
191
to
197
|
||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enqueueAllReleaseTargetsDesiredVersionreturns a Promise, but it's invoked withoutawait/error handling. If enqueueing fails (DB error, deadlock, etc.), this becomes an unhandled rejection and the reconciler work may silently not be scheduled. If this is intended to be fire-and-forget, consider explicitly discarding the promise and handling errors (e.g.,void ... .catch(...)); otherwiseawaitit so failures surface predictably.