zed-industries/zed · error · Error

Message method is undefined: ${JSON.stringify(message)}

Error message

Message method is undefined: ${JSON.stringify(message)}

What it means

Raised by the skill-import fetch in Zed's settings UI when a request to raw.githubusercontent.com that carries a Bearer GitHub token receives a 3xx redirect instead of file contents. raw.githubusercontent.com serves bytes directly for valid requests, so a redirect on an authenticated request almost always means GitHub is bouncing it to a sign-in or error page. Typical root causes: an expired/invalid token, a token without access to a private repo, or a repo that was renamed, transferred, or deleted after the URL was copied.

Source

Thrown at crates/prettier/src/prettier_server.js:152

      const messageEnd = headersLength + messageLength;
      const message = buffer.subarray(headersLength, messageEnd);
      buffer = buffer.subarray(messageEnd);
      headersLength = null;
      messageLength = null;
      yield message.toString("utf8");
    }
  } catch (e) {
    sendResponse(makeError(`Error reading stdin: ${e}`));
  } finally {
    process.stdin.off("data", () => {});
  }
}

async function handleMessage(message, prettier) {
  const { method, id, params } = message;
  if (method === undefined) {
    throw new Error(`Message method is undefined: ${JSON.stringify(message)}`);
  } else if (method == "initialized") {
    return;
  } else if (method === "shutdown") {
    sendResponse({ result: {} });
  } else if (method == "exit") {
    process.exit(0);
  }

  if (id === undefined) {
    throw new Error(`Message id is undefined: ${JSON.stringify(message)}`);
  }

  if (method === "prettier/format") {
    if (params === undefined || params.text === undefined) {
      throw new Error(`Message params.text is undefined: ${JSON.stringify(message)}`);
    }
    if (params.options === undefined) {
      throw new Error(`Message params.options is undefined: ${JSON.stringify(message)}`);

View on GitHub (pinned to f4178619ac)

Solutions

  1. Sign out and back in to GitHub in Zed so a fresh token is used, then retry the import
  2. Open the same raw URL in a browser where you are logged in to confirm the repo and path still exist
  3. If the repo was renamed or transferred, paste the updated owner/repo URL
  4. For private repos, make sure the authenticated account actually has access to that repository

Example fix

// before
let content = fetch_skill_file(&raw_url, github_token).await?; // redirect bail surfaces raw anyhow message

// after
let content = match fetch_skill_file(&raw_url, github_token).await {
    Ok(content) => content,
    Err(err) if err.to_string().contains("unexpected redirect") => {
        prompt_github_reauth().await?; // token stale or repo moved
        fetch_skill_file(&raw_url, fresh_token()).await?
    }
    Err(err) => return Err(err),
};
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: confirm the token is valid before fetching the raw file.
async fn github_token_is_valid(http_client: &HttpClient, token: &str) -> bool {
    let Ok(request) = http_client.get("https://api.github.com/user", Default::default()) else {
        return false;
    };
    let request = request.header("Authorization", format!("Bearer {token}"));
    matches!(http_client.send(request).await, Ok(response) if response.status().is_success())
}

Try / catch

match import_skill_from_url(&url, token).await {
    Err(err) if err.to_string().contains("unexpected redirect") => {
        // Token stale or repo moved: refresh auth, verify URL, then retry once.
        reauthenticate_github().await?;
        import_skill_from_url(&url, fresh_token()).await
    }
    result => result,
}

Prevention

When it happens

Trigger: Calling the skill-import fetch with a configured GitHub token (github_token.is_some()) where response.status().is_redirection(): expired OAuth token, token lacking scope for a private repo, renamed/transferred repo so the raw URL 301s, or a path that no longer exists.

Common situations: Importing a skill from a private repo after the GitHub session token expired; repo renamed or moved after the user copied the link; URL pasted from a fork whose upstream moved; corporate proxy injecting redirects.

Related errors


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