Skip to content

fix(deployments): word any 400 from cancel as cannot-be-cancelled - #290

Merged
Harshi-Shah-CS merged 1 commit into
v2-devfrom
CL-8788
Nov 18, 2026
Merged

Harshi-Shah-CS merged 1 commit into
v2-devfrom
CL-8788

Conversation

@Harshi-Shah-CS

@Harshi-Shah-CS Harshi-Shah-CS commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Jira: CL-8788

What

  • When the server refuses a cancel with a 400, deployments:cancel now shows the existing message
    Deployment "<uid>" cannot be cancelled because it is no longer in progress.
    instead of Launch API request failed with status 400.
  • This covers the race in the ticket: the deployment finishes between the CLI's in-progress check and the cancel request (for example, while the user reads "Are you sure?"), and the server answers {"errors":[{}]} with no code and no message.
  • The cancel endpoint only returns a 400 when the deployment can't be cancelled. An invalid UID fails earlier, when the CLI fetches the deployment, and a missing deployment is a 404. So any 400 now maps to this message. A launch.DEPLOYMENT.CANCEL_NOT_ALLOWED code 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 to HttpException, and the global exception filter only reads name/message from an object, so the message is dropped.

This PR does not depend on that fix:

  • Without the server fix, the CLI already shows the right message for any 400 from cancel.
  • With the server fix (a launch.DEPLOYMENT.CANCEL_NOT_ALLOWED code, on 400 or 409), the CLI recognises the code and shows the same message.
  • Server and CLI can deploy in either order.

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:
    • An empty {} error entry, and a 400 with some other message, now map to the message.
    • A 409 with the code keeps its status.
    • Non-400 refusals without the code (a 409 with only the raw message, a 404, a plain Error) pass through unchanged.
  • npm test passes in full. tsc --noEmit and eslint are clean. The pre-commit hooks pass (lint-staged, Talisman, trufflehog, Snyk).

#claude_code#
🤖 Generated with Claude Code

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>
@Harshi-Shah-CS
Harshi-Shah-CS requested review from a team as code owners November 18, 2026 07:30
@snyk-io

snyk-io Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 2 25 ✅ Passed
🟡 Medium Severity 0 1 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ 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:

  • Critical without fixes: 0
  • High without fixes: 2
  • Medium without fixes: 1
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@Harshi-Shah-CS
Harshi-Shah-CS merged commit 2c87380 into v2-dev Nov 18, 2026
7 checks passed
@Harshi-Shah-CS
Harshi-Shah-CS deleted the CL-8788 branch November 18, 2026 09:10

@dhruv-parekh-cs dhruv-parekh-cs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-built LaunchApiError is unit-tested, so parseErrorEnvelope/entryFrom → DeploymentsApi.cancel → command exit is never exercised for the empty entry. If a later change to entryFrom turns {} into something else, the unit test stays green while the command regresses to Launch 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

Comment thread src/deployments/deployments.api.ts Resolved
@Harshi-Shah-CS

Copy link
Copy Markdown
Contributor Author

@dhruv-parekh-cs thanks for the review. It landed just after this PR merged, so both lows are fixed in a follow-up, #292:

  • Integration case for {"errors":[{}]}: added ['an empty error entry', {}] to the refusal table in test/integration/deployments-cancel.test.ts, so the parse → DeploymentsApi.cancel → exit-1 path is covered at the wire.
  • Every 400 mapped to cancel wording: narrowed to the race only (inline reply above).

Harshi-Shah-CS added a commit that referenced this pull request Nov 18, 2026
#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants