Repository navigation
fix(deployments): word any 400 from cancel as cannot-be-cancelled - #290
Conversation
When a deployment finishes between the CLI's in-progress check and the
cancel request (often while the user reads the "Are you sure?" prompt),
the server refuses the cancel with a 400 whose body is {"errors":[{}]}:
no code and no message. The CLI did not recognise it and fell back to
"Launch API request failed with status 400."
The cancel endpoint only returns a 400 when the deployment can no longer
be cancelled (an invalid UID is caught earlier by the deployment
lookup), so treat any 400 from it as cancel-not-allowed and show the
existing message: Deployment "<uid>" cannot be cancelled because it is
no longer in progress. A refusal carrying the CANCEL_NOT_ALLOWED code is
still recognised on any status.
#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.
- Low
test/integration/deployments-cancel.test.ts:263(off-diff): the exact wire shape this PR fixes, a 400 with{"errors":[{}]}, has no integration case; only a hand-builtLaunchApiErroris unit-tested, soparseErrorEnvelope/entryFrom→DeploymentsApi.cancel→ command exit is never exercised for the empty entry. If a later change toentryFromturns{}into something else, the unit test stays green while the command regresses toLaunch API request failed with status 400.(AGENTS.md: a live-harness defect closes with a regression test at the wire). Fix: add['an empty error entry', {}]to the refusal table at line 263.
Cross-repo (CL-8788): no other open PR for the ticket; the server-side half is out of scope per the PR body.
— 🤖 launch-pr-review-agent (Claude)
Generated by Claude Code
|
@dhruv-parekh-cs thanks for the review. It landed just after this PR merged, so both lows are fixed in a follow-up, #292:
|
#292) * fix(deployments): word only the cancel race 400 as cannot-be-cancelled 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> * fix(deployments): judge the cancel race on the errors the server sent 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> * refactor(deployments): drop the comments added for the cancel race 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> --------- Co-authored-by: Claude <noreply@anthropic.com>
Jira: CL-8788
What
deployments:cancelnow shows the existing messageDeployment "<uid>" cannot be cancelled because it is no longer in progress.instead of
Launch API request failed with status 400.{"errors":[{}]}with no code and no message.launch.DEPLOYMENT.CANCEL_NOT_ALLOWEDcode is still recognised on any status.Server fix (separate, not needed by the CLI)
The ticket also covers a server bug: management-service sends an empty
{"errors":[{}]}body for this 400. The cancel controller passes a plain string toHttpException, and the global exception filter only readsname/messagefrom an object, so the message is dropped.This PR does not depend on that fix:
launch.DEPLOYMENT.CANCEL_NOT_ALLOWEDcode, on 400 or 409), the CLI recognises the code and shows the same message.The server fix is optional cleanup for other API callers. If it is done, it should be tracked separately, together with the other management-service call sites that pass a string to
HttpException.Tests
deployments.api.test.ts:{}error entry, and a 400 with some other message, now map to the message.Error) pass through unchanged.npm testpasses in full.tsc --noEmitand eslint are clean. The pre-commit hooks pass (lint-staged, Talisman, trufflehog, Snyk).#claude_code#
🤖 Generated with Claude Code