Skip to content

fix(cloud,cli): stale retry error no longer reclassifies a confirmed no-snapshot as unavailable - #479

Merged
jamesbhobbs merged 2 commits into
mainfrom
fix/stale-settle-retry-error
Aug 19, 2026
Merged

jamesbhobbs merged 2 commits into
mainfrom
fix/stale-settle-retry-error

Conversation

@jamesbhobbs

@jamesbhobbs jamesbhobbs commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes a misclassification voyti found post-merge on #448 (comment): during snapshot settling, the CLI accumulated onRetryError failures and threw the last one whenever content ended up null — even when a later status re-fetch succeeded and freshly confirmed that no snapshot was attached. A single early transient 503 therefore turned a confirmed artifactStatus: 'not_produced' into 'unavailable' with an unrelated network message.

Fix

The success signal only exists inside waitForRunSnapshot, so the tracking moves there:

  • waitForRunSnapshot clears its tracked re-fetch failure on every successful status re-fetch and reports it as SettledRunSnapshot.retryError — set only when the last re-fetch failed, i.e. when the final "no snapshot" observation rests on stale data.
  • The CLI throws settled.retryError instead of its own accumulated state; onRetryError remains a pure debug-logging hook.

Behavior matrix (null content):

Settle re-fetches Before After
all succeed not_produced not_produced
early failure, later success unavailable + stale network error not_produced
all fail (or last fails) unavailable unavailable

Test plan

  • New cloud tests: retryError cleared by a later successful re-fetch; reported when the final re-fetch failed
  • New CLI regression test: transient 503 then successful confirmation → not_produced, artifactError without the network message (fails on main)
  • Existing all-failed-re-fetches → unavailable test still passes
  • Full repo suite (2,919 tests), typecheck, biome/prettier, cspell green

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of temporary snapshot retrieval failures.
    • Successful follow-up checks now clear stale errors and correctly recognize when no snapshot was produced.
    • Final retrieval failures are reported accurately while cancellation errors continue to propagate.
  • Tests

    • Added coverage for transient and persistent snapshot retrieval failures.

…no-snapshot as unavailable

waitForRunSnapshot now clears its tracked re-fetch failure when a later
status re-fetch succeeds, and reports it on SettledRunSnapshot.retryError
only when the last re-fetch failed — i.e. when the final observation is
stale. The CLI throws settled.retryError instead of its own accumulated
onRetryError state, so an early transient 503 followed by a successful
re-fetch that freshly confirms no snapshot reports artifactStatus:
'not_produced' rather than 'unavailable' with an unrelated network message.
All-failed re-fetches still report unavailable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jamesbhobbs
jamesbhobbs requested a review from a team as a code owner August 19, 2026 19:06
@jamesbhobbs
jamesbhobbs requested a review from voyti August 19, 2026 19:06
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 06c35c2d-ce42-4e44-950a-25c889e7dc86

📥 Commits

Reviewing files that changed from the base of the PR and between a8ac188 and f70ee11.

📒 Files selected for processing (4)
  • packages/cli/src/utils/run-in-cloud.test.ts
  • packages/cli/src/utils/run-in-cloud.ts
  • packages/cloud/src/cloud-runs.test.ts
  • packages/cloud/src/cloud-runs.ts

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

waitForRunSnapshot now returns the latest non-abort status re-fetch error through retryError. Successful re-fetches clear this error. The CLI throws the error only when the settled result still indicates an unresolved re-fetch failure. A confirmed missing snapshot remains not_produced. Tests cover both recovery and persistent failure cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to f70ee

This localized change corrects stale retry-error classification and is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as run-in-cloud.ts
  participant SnapshotWaiter as waitForRunSnapshot
  participant StatusAPI as Cloud run status API
  CLI->>SnapshotWaiter: Settle snapshot retrieval
  SnapshotWaiter->>StatusAPI: Re-fetch run status
  StatusAPI-->>SnapshotWaiter: Transient failure
  SnapshotWaiter->>StatusAPI: Retry status fetch
  StatusAPI-->>SnapshotWaiter: Successful response with no snapshot
  SnapshotWaiter-->>CLI: content=null and retryError cleared
  CLI-->>CLI: Classify result as not_produced
Loading

Possibly related PRs

Suggested reviewers: voyti, dinohamzic

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Updates Docs ⚠️ Warning The fix adds public SettledRunSnapshot.retryError and changes snapshot classification, but e198ccd changes no documentation; retryError is absent from all Markdown docs. Document retryError and the final re-fetch behavior in packages/cloud/README.md and related CLI docs. Check the private internal roadmap separately; it is not available here.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: preventing stale retry errors from misclassifying confirmed no-snapshot results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.42%. Comparing base (a8ac188) to head (f70ee11).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #479   +/-   ##
=======================================
  Coverage   88.42%   88.42%           
=======================================
  Files         192      192           
  Lines       10757    10758    +1     
  Branches     3018     3018           
=======================================
+ Hits         9512     9513    +1     
  Misses       1243     1243           
  Partials        2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jamesbhobbs

Copy link
Copy Markdown
Member Author

Trivial, this merging w/o human review

@jamesbhobbs
jamesbhobbs merged commit 216f124 into main Aug 19, 2026
21 checks passed
@jamesbhobbs
jamesbhobbs deleted the fix/stale-settle-retry-error branch August 19, 2026 19:11
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.

1 participant