Skip to content

fix(tray): use /live instead of /api/v1/health for server readiness check#2523

Open
blackdeathdrow wants to merge 2 commits into
lemonade-sdk:mainfrom
blackdeathdrow:fix/tray-health-endpoint
Open

fix(tray): use /live instead of /api/v1/health for server readiness check#2523
blackdeathdrow wants to merge 2 commits into
lemonade-sdk:mainfrom
blackdeathdrow:fix/tray-health-endpoint

Conversation

@blackdeathdrow

Copy link
Copy Markdown
Contributor

The tray's wait_for_server() calls /api/v1/health to verify the server is running. When LEMONADE_API_KEY is set, this endpoint requires authentication, but the tray doesn't carry the API key — it gets a 401 and the check times out after 15 seconds, showing a spurious error dialog.

Switch to /live (the unauthenticated liveness endpoint) which was specifically added for this purpose (see #835).

Closes #2520.

@github-actions github-actions Bot added area::tray System tray app (LemonadeServer.exe, lemonade-tray) bug Something isn't working labels Jul 1, 2026

@fl0rianr fl0rianr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this fixes the 401 symptom but weakens the startup readiness contract.

The previous code intentionally used /api/v1/health instead of /live because /live can return before the model cache / model endpoints are ready. Switching wait_for_server() to /live makes the tray proceed as soon as the listener is alive, but TrayUI::build_menu() immediately calls /api/v1/health, /api/v1/models, and /internal/config, so this can reintroduce the early /models failure path that the old comment explicitly warned about.

The root issue seems narrower: wait_for_server()d oes not attach the same Authorization header that TrayUI::http_get() already attaches from LEMONADE_ADMIN_API_KEY / LEMONADE_API_KEY.

Suggested fix:

  • keep /api/v1/health as the readiness probe;
  • add the Bearer token header in wait_for_server();
  • ideally share the auth-header construction with TrayUI to avoid future drift;
  • add a regression test or at least a manual test note for LEMONADE_API_KEY startup.

/live is correct for Docker/Kubernetes liveness, but it looks too weak for tray readiness.

@blackdeathdrow blackdeathdrow force-pushed the fix/tray-health-endpoint branch from ea2b4c0 to 4fc3722 Compare July 2, 2026 06:39
…itching endpoint

Revert to /api/v1/health but attach the Authorization header from
LEMONADE_ADMIN_API_KEY or LEMONADE_API_KEY, matching the pattern
used by TrayUI::http_get() and http_post(). This preserves the
readiness semantics — /live can respond before the model cache
is built, causing failures on subsequent /models calls.
@blackdeathdrow blackdeathdrow force-pushed the fix/tray-health-endpoint branch from 1a7e36f to 846ee46 Compare July 2, 2026 06:56
@blackdeathdrow blackdeathdrow requested a review from fl0rianr July 2, 2026 06:58

@fl0rianr fl0rianr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this is now the right shape: it preserves the existing /api/v1/health readiness path and fixes only the missing auth header.

One tiny compile-hygiene nit before I’d approve: main.cpp now uses std::getenv, so please add #include <cstdlib> explicitly instead of relying on transitive includes, this would be cleaner.

@blackdeathdrow

Copy link
Copy Markdown
Contributor Author

Added #include <cstdlib>.

@blackdeathdrow blackdeathdrow requested a review from fl0rianr July 2, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area::tray System tray app (LemonadeServer.exe, lemonade-tray) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tray fails to start when LEMONADE_API_KEY is set

2 participants