fix: workspace link check retries once and reports a served saved link as a fallback

RA
2d ago
+349-37

Issue for this PR

Closes #1863

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The background check of which workspace a project is linked to (GET /datamate-project-bindings/by-remote and /by-path) failed outright on a single timeout or dropped connection. Every failure also reported workspace_api_error, even when the CLI went on serving the saved link and the user never noticed. These checks make up most of the workspace error rows.

  • The two lookups retry once after a failure with no status (a timeout or network error), a timeout while a 2xx body was still arriving, or a 502, 503 or 504. The retry goes out on a new connection, which Bun opens for keepalive: false, and runs as the same account as the first attempt. A 404 still means "not linked", and other statuses aren't retried. Only the last attempt's failure is reported, so a failure that the retry recovers from reports nothing.
  • When the lookup fails and the saved link is served instead, the failure is reported as the new workspace_link_check_stale (endpoint, status class, status). With no saved link it's still workspace_api_error, and a 401 is still workspace_auth_expired. The link and /workspace commands report as before.
  • A chat step still waits at most 1.5s for the link. The step races the lookup, so the retry only lengthens the background check.
  • A lookup that times out twice now takes 30s instead of 15s to fail, in link as well.
  • The telemetry reference documents the retry and the new event.

How did you verify your code works?

  • New tests cover:
    • A check that times out once and then answers returns the link with no row, and its retry was sent with keepalive off.
    • A dropped connection or a 502, 503 or 504 followed by an answer reports nothing.
    • Two failures report one workspace_api_error.
    • A 404, 403, 500 or 401 isn't retried.
    • With a saved link, two failures serve it as stale and send only workspace_link_check_stale. With none, they send workspace_api_error.
  • Against main's source, 6 of the new tests fail.
  • A Bun 1.3.14 probe: each request with keepalive: false opened a new connection, and the others reused the pooled one.
  • 210 tests pass across the 10 workspace and telemetry test files this touches, plus typecheck and the marker guard.

Cost side effects

None. At most one extra GET per failed link check.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

Codex review log: https://github.com/AltimateAI/altimate-code/pull/1865#issuecomment-7271036537

🤖 Generated with Claude Code

https://claude.ai/code/session_01BXxzvsr1G2qqFbMCyPZg3G

Summary by CodeRabbit

  • Bug Fixes
    • Workspace link lookups now retry once after network failures, timeouts, stalled responses, and temporary server errors (502, 503, or 504). If a retry fails while checking an existing saved link, the saved link remains available and the failure is reported separately. Other failures, including 401, 403, and 500, retain their distinct handling.
  • Documentation
    • Updated telemetry guidance to explain retry behavior and how final lookup failures are reported.