{"record":{"id":"bace3944017f94c6","repo":"xai-org/grok-build","slug":"notenabled","errorCode":"NotEnabled","errorMessage":"Device-code login is not available for this deployment. Try `grok login` or set XAI_API_KEY instead.","messagePattern":"Device-code login is not available for this deployment\\. Try `grok login` or set XAI_API_KEY instead\\.","errorType":"error_code","errorClass":"DeviceCodeError","httpStatus":404,"severity":"warning","filePath":"crates/codegen/xai-grok-shell/src/auth/device_code.rs","lineNumber":164,"sourceCode":"            .header(\"x-grok-client-version\", xai_grok_version::VERSION)\n            // Lets oauth2-provider separate human-completable logins from\n            // headless automation in the device-flow funnel metrics.\n            .header(\"x-grok-client-surface\", surface.as_str())\n            .form(&[\n                (\"client_id\", client_id),\n                (\"scope\", scope_str.as_str()),\n                (\"referrer\", \"grok-build\"),\n            ]),\n        &url,\n    )\n    .send()\n    .await?;\n\n    if !resp.status().is_success() {\n        let status = resp.status();\n        let body = resp.text().await.unwrap_or_default();\n        if status.as_u16() == 404 {\n            anyhow::bail!(DeviceCodeError::NotEnabled);\n        }\n        anyhow::bail!(\"Device code request failed (HTTP {status}): {body}\");\n    }\n\n    let server_resp: DeviceCodeResponse = resp.json().await?;\n\n    // Defend against control characters from a malicious issuer.\n    if !server_resp\n        .user_code\n        .chars()\n        .all(|c| c.is_ascii_alphanumeric() || c == '-')\n    {\n        anyhow::bail!(\"Server returned invalid user_code format (expected [A-Z0-9-])\");\n    }\n\n    validate_verification_uri(&server_resp.verification_uri)?;\n    if let Some(ref verification_uri_complete) = server_resp.verification_uri_complete {\n        validate_verification_uri(verification_uri_complete)?;","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/auth/device_code.rs#L146-L182","documentation":"request_device_code POSTs to the deployment's device-code endpoint to start device-code login. If the server answers HTTP 404, the endpoint is not deployed/enabled for this deployment, so the typed DeviceCodeError::NotEnabled is raised with this user-facing message suggesting alternatives. Other non-success statuses take the generic HTTP-error path (error 219).","triggerScenarios":"Calling run_device_code_login_channels -> request_device_code when the auth server returns 404 for the device-code initiation request, meaning the deployment disabled or never deployed device-code login.","commonSituations":"Self-hosted or enterprise deployments without the device-code route, API gateway path rewrites dropping the endpoint, hitting the wrong base URL (e.g. staging config against production), or server version older than the endpoint.","solutions":["Use `grok login` (interactive) instead of device-code flow","Set XAI_API_KEY in the environment and skip device login entirely","Confirm the deployment actually supports device-code login (check server version/config)","Verify the auth base URL configured for the client points at the correct deployment"],"exampleFix":"// before\ngrok login --device-code\n// after\nexport XAI_API_KEY=xai-...\ngrok login  # or rely on env key","handlingStrategy":"fallback","validationCode":"// Probe whether the deployment supports device-code login\nlet probe = client.post(device_code_url).send().await?;\nif probe.status() == reqwest::StatusCode::NOT_FOUND {\n    eprintln!(\"device-code login disabled here; use API key\");\n}","typeGuard":null,"tryCatchPattern":"match request_device_code(&client, &cfg).await {\n    Ok(dc) => dc,\n    Err(e) if matches!(*e.downcast::<DeviceCodeError>().unwrap_or_default(), DeviceCodeError::NotEnabled) => {\n        eprintln!(\"falling back to `grok login` / XAI_API_KEY\");\n        fallback_login().await?\n    },\n    Err(e) => return Err(e),\n}","preventionTips":["Always offer API-key auth as an alternative in scripts","Confirm deployment feature support before defaulting to device-code login","Verify base URL/config points at a deployment that exposes the endpoint"],"tags":["auth","device-code","http-404","configuration"],"backgroundTag":"endpoint-not-enabled-404","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}