{"record":{"id":"f49dae2a0d82edcf","repo":"astral-sh/uv","slug":"failed-to-fetch-credentials-for-display-url","errorCode":null,"errorMessage":"Failed to fetch credentials for {display_url}","messagePattern":"Failed to fetch credentials for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/uv/src/commands/auth/token.rs","lineNumber":67,"sourceCode":"        (Some(cli), None) => cli,\n        (None, Some(url)) => url.to_string(),\n        (None, None) => \"__token__\".to_string(),\n    };\n    if username.is_empty() {\n        bail!(\"Username cannot be empty\");\n    }\n\n    let display_url = if username == \"__token__\" {\n        url.without_credentials().to_string()\n    } else {\n        format!(\"{username}@{}\", url.without_credentials())\n    };\n\n    let credentials = match &backend {\n        AuthBackend::System(provider) => provider\n            .fetch(url, Some(&username))\n            .await\n            .ok_or_else(|| anyhow::anyhow!(\"Failed to fetch credentials for {display_url}\"))?,\n        AuthBackend::TextStore(store, _lock) => store\n            .get_credentials(url, Some(&username))?\n            .cloned()\n            .ok_or_else(|| anyhow::anyhow!(\"Failed to fetch credentials for {display_url}\"))?,\n    };\n\n    let Some(password) = credentials.password() else {\n        bail!(\n            \"No {} found for {display_url}\",\n            if username != \"__token__\" {\n                \"password\"\n            } else {\n                \"token\"\n            }\n        );\n    };\n\n    writeln!(printer.stdout(), \"{password}\")?;","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/astral-sh/uv/blob/f1a42680ff5272232d65748acf338b19778dde24/crates/uv/src/commands/auth/token.rs#L49-L85","documentation":"Raised by `uv token` when the system credential backend (keyring, selected via --keyring-provider) returns nothing for the given URL and username. The provider's async fetch returned None/failed, so no Credentials could be located and the command cannot print a token. The message includes the display URL (and username if not the default __token__ user).","triggerScenarios":"Running `uv token <url>` with --keyring-provider subprocess while the OS keyring has no entry for that service/username; keyring daemon unavailable or locked (e.g., no D-Bus secret service on a headless Linux box); entry stored under a different username than the one resolved (CLI --username vs URL-embedded vs default __token__).","commonSituations":"Fresh machine without stored credentials; Linux server without gnome-keyring running; credentials were stored by an older uv under a normalized URL so the lookup key mismatches; username mismatch (stored as __token__ but queried with a real username).","solutions":["Store credentials first with `uv login <url>` (or `uv ... --keyring-provider` flow) so the keyring has an entry for this exact URL and username.","Verify the keyring backend works headless: install/start a secret service (gnome-keyring + D-Bus) or use a CLI keyring backend uv can shell out to.","Match the username: query with the same `--username` (or URL credentials) that was used when storing; default lookups use `__token__`.","Check the exact URL spelling/scheme — keyring entries are keyed per service URL, so https vs http or trailing path differences cause a miss."],"exampleFix":"# before\nuv token https://pypi.internal/simple --keyring-provider subprocess  # -> Failed to fetch credentials\n# after\nuv login https://pypi.internal/simple   # store once\nuv token https://pypi.internal/simple --keyring-provider subprocess","handlingStrategy":"validation","validationCode":"# Rust: probe the keyring before running `uv token`\nlet creds = provider.fetch(url, Some(&username)).await;\nif creds.is_none() {\n    anyhow::bail!(\n        \"no keyring entry for {username}@{url}; run `uv login {url}` first\"\n    );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `uv login <url>` before `uv token <url>` on a new machine.","On headless Linux, ensure a secret service (gnome-keyring + D-Bus) is running before relying on the keyring backend.","Always query with the same username used when storing (default is `__token__`)."],"tags":["auth","keyring","credentials","token"],"backgroundTag":null,"analyzedSha":"f1a42680ff5272232d65748acf338b19778dde24","analyzedAt":"2026-08-16T04:51:47.599Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}