fix(cli): point at an API key where the device flow is not served - #622
Open
mikhail-koviazin wants to merge 1 commit into
Open
fix(cli): point at an API key where the device flow is not served#622mikhail-koviazin wants to merge 1 commit into
mikhail-koviazin wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
hud logincannot succeed againstapi.hud.ai:The command posts to
{settings.hud_api_url}/auth/device/code, and that route is not there under any prefix:POST /auth/device/codenot_foundPOST /v1/auth/device/codePOST /v2/auth/device/codePOST /v3/auth/device/codeThe platform itself answers, so this is neither the base URL nor the network:
GET /v2/jobsunauthorizedGET /v2/modelsGET /openapi.jsonThe published contract has no such route either:
https://api.hud.ai/openapi.json(HUD Platform 2.0.0) lists 103 paths, none of them containingauth,device,loginortoken.Users are pointed at the command anyway.
docs/v6/reference/cli.mdxlistshud login | Authenticate with HUD., andrequire_api_keymakes it the first suggestion when a key is missing, ahead of the route that does work:What
A 404 from the device-code endpoint gets its own branch, so the one outcome every user currently reaches says what to do about it:
The wording is taken from
require_api_keyso the two messages agree. The branch is reached only on 404, so if the device flow ships later it stops firing on its own, and nothing else about the flow changes.Deliberately left alone: whether
hud loginshould exist while it cannot work, and the order of the hints inrequire_api_key. Those are product calls, not bugs.Tests
hud/cli/tests/test_login.pyis the first coveragelogin.pyhas. It drives the command throughCliRunnerwith only the transport mocked, so the request path that runs is the real one.The first fails on
mainand the second passes there, which is why both are here.Validation
uv run pytest -quv run ruff format . --checkanduv run ruff check .uv run --extra dev --extra train --extra modal --extra daytona ty check --error-on-warningapi.hud.ai, not written by hand.Note
Low Risk
CLI-only error messaging and tests; no auth, API contract, or credential handling changes beyond clearer 404 UX.
Overview
When
hud logingets a 404 fromPOST /auth/device/code, it no longer dumps the response body like a generic API failure. It explains that this deployment does not support browser/device login and steers users tosettings.hud_web_url/settings andhud set HUD_API_KEY=..., aligned with the missing-key hints elsewhere in the CLI.Non-404 errors on that request are unchanged: status code plus response snippet, exit 1.
Adds
hud/cli/tests/test_login.py, exercising the real login command viaCliRunnerwith onlyhttpx.Clienttransport mocked—404 must mention API-key setup; 503 must still surface the upstream body.Reviewed by Cursor Bugbot for commit 3d598a8. Bugbot is set up for automated code reviews on this repo. Configure here.