Skip to content

fix(crew): stop startup validation logging a false-positive error on healthy boots - #99

Open
abhishekmishragithub wants to merge 1 commit into
mainfrom
fix-crew-startup-false-positive
Open

fix(crew): stop startup validation logging a false-positive error on healthy boots#99
abhishekmishragithub wants to merge 1 commit into
mainfrom
fix-crew-startup-false-positive

Conversation

@abhishekmishragithub

Copy link
Copy Markdown
Collaborator

Problem

The crew server dry-runs your setup_handler at startup to catch node __init__ / import / missing-env / graph errors before accepting traffic. But the canonical handler ends with await session.start(), and the dry-run intentionally skips session.initialize(), so start() hit raise ValueError("Session not initialized") on every healthy boot:

ERROR | Startup validation failed — pod will not accept sessions. ValueError: Session not initialized

It also left the pod _ready = False for perfectly correct code. The docs had to tell users to ignore this scary error (quickstart "Expected boot output" note).

Fix

Add a dry-run mode to CrewSession:

  • _dry_run is set only by the server's validator (real sessions never set it).
  • In session.start(), when _dry_run is set: build the graph (still surfaces node/edge/cycle errors), then raise an internal _StartupProbeComplete to halt cleanly, without requiring the init handshake or starting nodes (no external connections).
  • The validator swallows that sentinel and marks the pod ready.

Genuinely broken handlers (node __init__ raising, imports, cycles) still fail validation and keep the pod not-ready, with a real reason. The live session path is untouched.

Result

  • Healthy crews: no error, pod correctly reports ready.
  • Broken crews: still fail fast with the real cause.
  • The docs "ignore this error" note can be removed (follow-up docs PR).

Tests

  • Canonical handler (ends with session.start()) passes validation, _ready true.
  • Handler whose node __init__ raises fails validation, _ready false with the reason.
  • Dry-run start() builds the graph and raises the sentinel with no init event.

Green locally: ruff 0.16.1 (check + format), mypy 1.13.0, pytest (crew suite 26 passed).

Held for review.

The crew server dry-runs setup_handler at startup to catch node __init__ /
import / missing-env / graph errors before accepting traffic. The canonical
handler ends with `await session.start()`, but the dry-run intentionally skips
`session.initialize()`, so start() hit `raise ValueError('Session not
initialized')` on every healthy boot. That logged:

  ERROR | Startup validation failed — pod will not accept sessions.
          ValueError: Session not initialized

and left the pod _ready=False, for perfectly correct code. Users had to be
told in the docs to ignore it.

Add a dry-run mode: in `session.start()`, when _dry_run is set, build the graph
(still surfaces node/edge/cycle errors) and raise an internal
_StartupProbeComplete to halt cleanly, without requiring the init handshake or
starting nodes. The validator swallows that sentinel and marks the pod ready.
Genuinely broken handlers (node __init__ raising, imports, cycles) still fail
validation and keep the pod not-ready. The real session path is untouched
(_dry_run is only set by the validator).

Tests: canonical handler passes, broken handler fails, dry-run start() builds
the graph and raises the sentinel without an init event.
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