Repository: astral-sh/uv
File: crates/uv/src/commands/auth/helper.rs (Rust)

Code before:
    let username = url_username.map(ToString::to_string);

    if pyx_store.is_known_domain(url) {
        if username.is_some() {
            bail!(
                "Cannot specify a username for URLs under {}",
                url.host()
                    .map(|host| host.to_string())
                    .unwrap_or("this host".to_owned())
            );
        }
        let client = BaseClientBuilder::new(
            network_settings.connectivity,
            network_settings.native_tls,
            network_settings.allow_insecure_host.clone(),
            preview,
            network_settings.timeout,
            network_settings.retries,
        )
        .auth_integration(uv_client::AuthIntegration::NoAuthMiddleware)
        .build();
        let maybe_token = pyx_store
            .access_token(client.for_host(pyx_store.api()).raw_client(), 0)
            .await
            .context("Authentication failure")?;
        let token = maybe_token.ok_or_else(|| anyhow::anyhow!("No access token found"))?;
        return Ok(Some(Credentials::bearer(token.into_bytes())));
    }
    let backend = AuthBackend::from_settings(preview)?;
    let credentials = match &backend {
        AuthBackend::System(provider) => provider.fetch(url, username.as_deref()).await,
        AuthBackend::TextStore(store, _lock) => {
            store.get_credentials(url, username.as_deref()).cloned()
        }
    };
    Ok(credentials)
}

/// Implement the Bazel credential helper protocol.
///
/// Reads a JSON request from stdin containing a URI, looks up credentials
/// for that URI using uv's authentication backends, and writes a JSON response
/// to stdout containing HTTP headers (if credentials are found).
///
/// Protocol specification TLDR:
/// - Input (stdin): `{"uri": "https://example.com/path"}`
/// - Output (stdout): `{"headers": {"Authorization": ["Basic ..."]}}` or `{"headers": {}}`
/// - Errors: Written to stderr with non-zero exit code
///
/// Full spec is [available here](https://github.com/bazelbuild/proposals/blob/main/designs/2022-06-07-bazel-credential-helpers.md)
pub(crate) async fn helper(

Review comment (suggestion):
```suggestion
        let token = maybe_token.context("No access token found")?;
```

Code after:
    {
        debug!("URL '{url}' contain a password; ignoring");
    }

    if pyx_store.is_known_domain(url) {
        if username.is_some() {
            bail!(
                "Cannot specify a username for URLs under {}",
                url.host()
                    .map(|host| host.to_string())
                    .unwrap_or(url.to_string())
            );
        }
        let client = BaseClientBuilder::new(
            network_settings.connectivity,
            network_settings.native_tls,
            network_settings.allow_insecure_host.clone(),
            preview,
            network_settings.timeout,
            network_settings.retries,
        )
        .auth_integration(uv_client::AuthIntegration::NoAuthMiddleware)
        .build();
        let token = pyx_store
            .access_token(client.for_host(pyx_store.api()).raw_client(), 0)
            .await
            .context("Authentication failure")?
            .context("No access token found")?;
        return Ok(Some(Credentials::bearer(token.into_bytes())));
    }
    let backend = AuthBackend::from_settings(preview).await?;
    let credentials = match &backend {
        AuthBackend::System(provider) => provider.fetch(url, username).await,
        AuthBackend::TextStore(store, _lock) => store.get_credentials(url, username).cloned(),
    };
    Ok(credentials)
}

/// Implement the Bazel credential helper protocol.
///
/// Reads a JSON request from stdin containing a URI, looks up credentials
/// for that URI using uv's authentication backends, and writes a JSON response
/// to stdout containing HTTP headers (if credentials are found).
///
/// Protocol specification TLDR:
/// - Input (stdin): `{"uri": "https://example.com/path"}`
/// - Output (stdout): `{"headers": {"Authorization": ["Basic ..."]}}` or `{"headers": {}}`
/// - Errors: Written to stderr with non-zero exit code
///
/// Full spec is [available here](https://github.com/bazelbuild/proposals/blob/main/designs/2022-06-07-bazel-credential-helpers.md)
pub(crate) async fn helper(