Repository navigation
fix(deployments): word only the cancel race 400 as cannot-be-cancelled - #292
Conversation
Follow-up to #290 review. Treating every 400 from cancel as "no longer in progress" could misreport a gateway 400 with no error body, or a validation 400 with its own code, while the deployment is still running. The cancel-not-allowed wording now applies to: - the CANCEL_NOT_ALLOWED code, on any status - a 400 carrying the server's raw refusal message - a 400 whose error entries are all empty, which is what the server sends when the deployment finishes before the cancel lands Any other 400 keeps its own wording. Adds an integration case for the {"errors":[{}]} body, so the parse-to-exit path is covered. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
dhruv-parekh-cs
left a comment
There was a problem hiding this comment.
Reviewed the whole PR: 0 high, 0 medium, 2 low (inline).
— 🤖 launch-pr-review-agent (Claude)
Generated by Claude Code
sanikapareek-contentstack
left a comment
There was a problem hiding this comment.
Reviewed the narrowed cancel-refusal check. The direction is right, and the race case plus the negative cases are well covered. I left one medium comment inline: the "all entries empty" test runs on the parsed entries, so it matches more bodies than {"errors":[{}]}.
Low priority
- No negative case at the wire.
test/integration/deployments-cancel.test.tsgained the positive{}case but has no 400 that should not get the cancel wording, such as{"errors":[]}, a body with noerrorskey, or{"errors":[{"message":"something else"}]}. The unit tests cover this throughDeploymentsApi, but one row at the wire would pin parse → map → exit message end to end for the case the PR exists to fix. - Overlapping tests for the invalid-UID code.
['another known code', [{ code: INVALID_DEPLOYMENT_UID_CODE }]]in the "untouched" table and the separatekeeps the wording of another known code…test build the same rejection. One checks identity (rejects.toBe) and the other checks the message, so you could fold the message assertion into one test. This is a nit. - Comment and naming in
deployments.api.ts. The comment aboveisCancelRaceRefusal(L50) describes only the{"errors":[{}]}shape, but the function also matches the raw refusal message on any 400. Consider documenting both.isEmptyis a generic module-level name;isEmptyEntrywould read better next toisRawRefusal. - The fix depends on undocumented server behavior. The client now infers "deployment finished" from an empty error entry, which only holds while the server keeps sending that shape for the race. A backend ticket to return
launch.DEPLOYMENT.CANCEL_NOT_ALLOWEDfor the race would let this heuristic go away. Consider linking one from CL-8788.
#claude_code#
Address #292 review. The race check matched any 400 whose parsed entries were all empty, but the parser reduces every entry it can't read (a string, null, a non-string code, unknown keys, a field with a plain string value) to {}. Those 400s still said the deployment was no longer in progress. LaunchApiError now keeps the errors array as the server sent it (rawErrors; hand-built errors default to their own entries), and the cancel check matches only literal {} entries there. Also adds wire-level cases for 400s that must keep their own wording, drops a duplicate invalid-UID row, renames isEmpty to isEmptyEntry and documents both race shapes. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
@sanikapareek-contentstack thanks for the review. Your review-body points, in 5287886:
|
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
dhruv-parekh-cs
left a comment
There was a problem hiding this comment.
Re-review since bf3e05c (through 5287886): 0 high, 0 medium, 1 low (inline). Both earlier lows are fixed: the race check now judges literal {} on rawErrors, and the wire-level suite covers the leave-untouched path.
— 🤖 launch-pr-review-agent (Claude)
Generated by Claude Code
AGENTS.md: "Do not create code comments for any changes." The test names already document the race body. The rawErrors JSDoc also overstated it: for hand-built errors it holds the hand-built entries, not what the server sent. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
sanikapareek-contentstack
left a comment
There was a problem hiding this comment.
Re-reviewed at 5287886. The medium finding is resolved: the race check now uses rawErrors, the errors array exactly as the server sent it, and isEmptyEntry matches only a literal {}. isRecord excludes arrays, so [[]], strings, null and other-key entries no longer get the cancel wording. The cancel path throws parseErrorEnvelope straight from rest-client, and nothing rewraps the error on the way to DeploymentsApi.cancel, so rawErrors survives to the check. The new wire rows cover each shape end to end, and my earlier lows are addressed or answered.
One low remains, non-blocking: the rawErrors default (= errors) means a hand-built or rebuilt error reports its parsed entries as "what was sent". That's harmless today because no rebuilt error reaches the cancel path, but the JSDoc slightly overstates it. Dhruv's note about the AGENTS.md no-comments rule covers the same lines.
LGTM.
#claude_code#
770d692
|
@sanikapareek-contentstack a correction to point 3 of my earlier reply: per |
|
@sanikapareek-contentstack thanks. Your remaining low (the |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
sanikapareek-contentstack
left a comment
There was a problem hiding this comment.
Re-reviewed since 5287886 (through 770d692): 0 high, 0 medium, 0 low.
- cf68dcb only removes the race-check comment and the
rawErrorsJSDoc, which resolves my remaining low and Dhruv's AGENTS.md note. There is no logic change. - The v2-dev merge (#291) leaves
deployments.api.tsandtransport/errors.tsuntouched apart from cf68dcb. None of the merged-in code constructsLaunchApiErroror readserrors/rawErrors, so it doesn't interact with the race check.
LGTM.
#claude_code#
dhruv-parekh-cs
left a comment
There was a problem hiding this comment.
Re-review since 5287886 (through 770d692), checked against the whole PR diff: 0 high, 0 medium, 0 low. The earlier low (the new code comments) is fixed in cf68dcb, and the v2-dev merge adds nothing to this PR's own diff. Nothing from earlier reviews is still open.
— 🤖 launch-pr-review-agent (Claude)
Generated by Claude Code
Jira: CL-8788
Follow-up to #290, addressing this review (both lows).
What
Deployment "<uid>" cannot be cancelled because it is no longer in progress.for every 400 from cancel. A gateway 400 with no error body, or a validation 400 with its own code, would tell the user the deployment finished while it may still be running.launch.DEPLOYMENT.CANCEL_NOT_ALLOWEDcode, on any status{"errors":[{}]}, which the server sends when the deployment finishes before the cancel lands (the race in the ticket)LaunchApiError.rawErrors), not the parsed entries. The parser turns any entry it can't read (a string, null, a non-string code, unknown keys) into{}, and those must not count as the race.Tests
deployments.api.test.ts:deployments-cancel.test.ts: the{"errors":[{}]}body now has a case at the wire, covering parse →DeploymentsApi.cancel→ exit 1 with the cancel wording.deployments-cancel.test.ts: 8 wire-level 400s keep their own wording (no errors array, another message, a string, null, an array, a numeric code, other keys, a field with a string value).errors.test.ts: the parser keeps the raw errors array; hand-built errors default to their own entries.npm testpasses in full (3837 tests);deployments.api.tsis at 100% coverage. eslint andtsc --noEmitare clean. The pre-commit hooks pass (lint-staged, Talisman, trufflehog, Snyk).#claude_code#
🤖 Generated with Claude Code