Skip to content

fix(deployments): word only the cancel race 400 as cannot-be-cancelled - #292

Merged
Harshi-Shah-CS merged 4 commits into
v2-devfrom
CL-8788
Nov 18, 2026
Merged

Harshi-Shah-CS merged 4 commits 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

Follow-up to #290, addressing this review (both lows).

What

  • fix(deployments): word any 400 from cancel as cannot-be-cancelled #290 showed 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.
  • The wording now applies only to:
    • the launch.DEPLOYMENT.CANCEL_NOT_ALLOWED code, on any status
    • a 400 carrying the server's raw refusal message
    • a 400 whose error entries are all empty: {"errors":[{}]}, which the server sends when the deployment finishes before the cancel lands (the race in the ticket)
  • Any other 400 keeps its own wording (for example the invalid-UID message).
  • The empty-entry check reads the errors array as the server sent it (new 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:
    • New: a 400 with another message, no entries, an empty entry beside another message, another known code, or a field-only entry passes through unchanged.
    • New: a 400 with the invalid-UID code keeps its own wording.
    • New: several empty entries still map to the cancel wording.
  • 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.
  • Mutation-checked: removing any part of the new condition (status, non-empty, empty-entry, field, raw message) fails a test.
  • npm test passes in full (3837 tests); deployments.api.ts is at 100% coverage. eslint and tsc --noEmit are clean. The pre-commit hooks pass (lint-staged, Talisman, trufflehog, Snyk).

#claude_code#
🤖 Generated with Claude Code

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

@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 (inline).

— 🤖 launch-pr-review-agent (Claude)


Generated by Claude Code

Comment thread src/deployments/deployments.api.ts Resolved

@sanikapareek-contentstack sanikapareek-contentstack left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. No negative case at the wire. test/integration/deployments-cancel.test.ts gained the positive {} case but has no 400 that should not get the cancel wording, such as {"errors":[]}, a body with no errors key, or {"errors":[{"message":"something else"}]}. The unit tests cover this through DeploymentsApi, but one row at the wire would pin parse → map → exit message end to end for the case the PR exists to fix.
  2. Overlapping tests for the invalid-UID code. ['another known code', [{ code: INVALID_DEPLOYMENT_UID_CODE }]] in the "untouched" table and the separate keeps 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.
  3. Comment and naming in deployments.api.ts. The comment above isCancelRaceRefusal (L50) describes only the {"errors":[{}]} shape, but the function also matches the raw refusal message on any 400. Consider documenting both. isEmpty is a generic module-level name; isEmptyEntry would read better next to isRawRefusal.
  4. 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_ALLOWED for the race would let this heuristic go away. Consider linking one from CL-8788.

#claude_code#

Comment thread src/deployments/deployments.api.ts Resolved
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>
@Harshi-Shah-CS

Copy link
Copy Markdown
Contributor Author

@sanikapareek-contentstack thanks for the review. Your review-body points, in 5287886:

  1. No negative case at the wire: added (8 wire rows, see the inline reply).
  2. Overlapping invalid-UID tests: dropped the row from the "untouched" table. The separate test asserts the wording.
  3. Comment and naming: isEmpty is now isEmptyEntry, and the comment covers both race shapes ({"errors":[{}]} and the raw refusal message).
  4. Backend ticket: not adding one. We decided the server fix is out of scope for CL-8788, since the CLI does not need it. If the server ever sends launch.DEPLOYMENT.CANCEL_NOT_ALLOWED, the CLI already recognises the code on any status. The PR fix(deployments): word any 400 from cancel as cannot-be-cancelled #290 description records this decision.

@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

@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.

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

Comment thread src/deployments/deployments.api.ts Resolved
Harshi-Shah-CS and others added 2 commits November 18, 2026 16:29
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 sanikapareek-contentstack left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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#

@Harshi-Shah-CS

Copy link
Copy Markdown
Contributor Author

@sanikapareek-contentstack a correction to point 3 of my earlier reply: per AGENTS.md ("Do not create code comments for any changes"), the comment above isCancelRaceRefusal is now removed (cf68dcb, flagged in Dhruv's re-review). The isEmptyEntry rename stays. The test names describe both race shapes: {"errors":[{}]} and the raw refusal message.

@Harshi-Shah-CS

Copy link
Copy Markdown
Contributor Author

@sanikapareek-contentstack thanks. Your remaining low (the rawErrors JSDoc overstating "what was sent" for hand-built errors) is resolved by cf68dcb, which removes that JSDoc under the AGENTS.md no-comments rule. The push (cf68dcb plus a v2-dev merge for #291) dismissed the approvals at 5287886, so it needs a fresh approve at 770d692.

@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

@sanikapareek-contentstack sanikapareek-contentstack left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Re-reviewed since 5287886 (through 770d692): 0 high, 0 medium, 0 low.

  • cf68dcb only removes the race-check comment and the rawErrors JSDoc, which resolves my remaining low and Dhruv's AGENTS.md note. There is no logic change.
  • The v2-dev merge (#291) leaves deployments.api.ts and transport/errors.ts untouched apart from cf68dcb. None of the merged-in code constructs LaunchApiError or reads errors/rawErrors, so it doesn't interact with the race check.

LGTM.

#claude_code#

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

@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.

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

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.

3 participants