zed-industries/zed · error

invalid resource_metadata URL

Error message

invalid resource_metadata URL: {}

What it means

parse_www_authenticate extracts the resource_metadata parameter from a WWW-Authenticate header and parses it as a URL; this error fires when that value is present but malformed and fails Url::parse. The header value from the server is the input at fault.

Solutions

  1. Verify the protected resource emits a syntactically valid resource_metadata URL
  2. Correct server configuration or the protected resource metadata URL
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/context_server/src/oauth.rs:299 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/b6437c7ae64f57b4. Report an issue: GitHub.

Appendix: source

Thrown at crates/context_server/src/oauth.rs:299

        bail!("WWW-Authenticate header does not use Bearer scheme");
    };

    if params_str.is_empty() {
        return Ok(WwwAuthenticate {
            resource_metadata: None,
            scope: None,
            error: None,
            error_description: None,
        });
    }

    let params = parse_auth_params(params_str);

    let resource_metadata = params
        .get("resource_metadata")
        .map(|v| Url::parse(v))
        .transpose()
        .map_err(|e| anyhow!("invalid resource_metadata URL: {}", e))?;

    let scope = params
        .get("scope")
        .map(|v| v.split_whitespace().map(String::from).collect());

    let error = params.get("error").map(|v| BearerError::parse(v));
    let error_description = params.get("error_description").cloned();

    Ok(WwwAuthenticate {
        resource_metadata,
        scope,
        error,
        error_description,
    })
}

/// Parse comma-separated `key="value"` or `key=token` parameters from an
/// auth-param list (RFC 7235 Section 2.1).

View on GitHub (pinned to f4178619ac)