zed-industries/zed · error

failed to build permalink

Error message

failed to build permalink

What it means

A URL-construction guard in build_permalink: it joins '{owner}/_git/{repo}' (plus optional path/selection query parameters) onto the Azure base_url and panics via expect if Url::join produces an error. As with the commit permalink, this fires when the base URL is not a valid base or the owner/repo/path components contain characters that cannot form a valid URL, e.g. a repo name with a space or an empty owner.

Source

Thrown at crates/git_hosting_providers/src/providers/azure.rs:144

            .base_url()
            .join(&format!("{owner}/_git/{repo}/commit/{sha}"))
            .expect("failed to build commit permalink");
        url.set_query(None);
        url
    }

    fn build_permalink(&self, remote: ParsedGitRemote, params: BuildPermalinkParams) -> Url {
        let ParsedGitRemote { owner, repo } = remote;
        let BuildPermalinkParams {
            sha,
            path,
            selection,
        } = params;

        let mut permalink = self
            .base_url()
            .join(&format!("{owner}/_git/{repo}"))
            .expect("failed to build permalink");

        let mut query = format!("path=/{path}&version=GC{sha}");
        if let Some(selection) = selection {
            query.push('&');
            query.push_str(&self.line_fragment(&selection));
        }
        permalink.set_query(Some(&query));

        permalink
    }

    fn build_create_pull_request_url(
        &self,
        remote: &ParsedGitRemote,
        source_branch: &str,
    ) -> Option<Url> {
        let ParsedGitRemote { owner, repo } = remote;
        let encoded_source = urlencoding::encode(source_branch);

View on GitHub (pinned to f4178619ac)

Solutions

  1. Change the permalink builders' contract to return Option/Result and degrade to no link when construction fails
  2. URL-encode each dynamic path segment before formatting it into the join string
  3. Reject or normalize malformed remote URLs earlier, when ParsedGitRemote is produced
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/git_hosting_providers/src/providers/azure.rs:144 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/63f167e126288d55. Report an issue: GitHub.