Skip to content

fix(sidecar): stop loops and surface re-auth message on invalid_grant#57

Draft
VishiATChoudhary wants to merge 1 commit intofix/54-clear-stale-sessionfrom
fix/54-sidecar-shutdown-on-auth-loss
Draft

fix(sidecar): stop loops and surface re-auth message on invalid_grant#57
VishiATChoudhary wants to merge 1 commit intofix/54-clear-stale-sessionfrom
fix/54-sidecar-shutdown-on-auth-loss

Conversation

@VishiATChoudhary
Copy link
Copy Markdown
Collaborator

Summary

  • explain the user-facing change
  • link the issue or context if relevant

Verification

  • go test ./...
  • go test -race ./...
  • go vet ./...
  • buf generate if protobuf or generated code changed

Release notes

  • conventional commit title matches semver intent

When the heartbeat or event-ingestion path receives an error wrapping
auth.ErrInvalidGrant, the sidecar now:
  1. Prints a single stderr message telling the user to run
     `kontext login` (guarded by sync.Once so duplicate triggers from
     concurrent heartbeat + ingest paths don't spam).
  2. Cancels the sidecar context to stop both loops cleanly.

The agent child process keeps running — users can finish their in-flight
work without telemetry and re-authenticate on next `kontext start`.
Transient errors (network, 5xx) still log and retry exactly as before;
only permanent auth failures trigger the new shutdown path.

For testability: the client field is now an unexported backendClient
interface (still satisfied by *backend.Client), and the heartbeat ticker
interval is a field on Server so tests can set it to a few milliseconds.

Closes #54
Copy link
Copy Markdown
Collaborator Author

VishiATChoudhary commented Apr 13, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

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