{"record":{"id":"8dd0b6471aabfee0","repo":"zed-industries/zed","slug":"message-method-is-undefined-json-stringify-mess","errorCode":null,"errorMessage":"Message method is undefined: ${JSON.stringify(message)}","messagePattern":"Message method is undefined: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/prettier/src/prettier_server.js","lineNumber":152,"sourceCode":"\n      const messageEnd = headersLength + messageLength;\n      const message = buffer.subarray(headersLength, messageEnd);\n      buffer = buffer.subarray(messageEnd);\n      headersLength = null;\n      messageLength = null;\n      yield message.toString(\"utf8\");\n    }\n  } catch (e) {\n    sendResponse(makeError(`Error reading stdin: ${e}`));\n  } finally {\n    process.stdin.off(\"data\", () => {});\n  }\n}\n\nasync function handleMessage(message, prettier) {\n  const { method, id, params } = message;\n  if (method === undefined) {\n    throw new Error(`Message method is undefined: ${JSON.stringify(message)}`);\n  } else if (method == \"initialized\") {\n    return;\n  } else if (method === \"shutdown\") {\n    sendResponse({ result: {} });\n  } else if (method == \"exit\") {\n    process.exit(0);\n  }\n\n  if (id === undefined) {\n    throw new Error(`Message id is undefined: ${JSON.stringify(message)}`);\n  }\n\n  if (method === \"prettier/format\") {\n    if (params === undefined || params.text === undefined) {\n      throw new Error(`Message params.text is undefined: ${JSON.stringify(message)}`);\n    }\n    if (params.options === undefined) {\n      throw new Error(`Message params.options is undefined: ${JSON.stringify(message)}`);","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/prettier/src/prettier_server.js#L134-L170","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Sign out and back in to GitHub in Zed so a fresh token is used, then retry the import","Open the same raw URL in a browser where you are logged in to confirm the repo and path still exist","If the repo was renamed or transferred, paste the updated owner/repo URL","For private repos, make sure the authenticated account actually has access to that repository"],"exampleFix":"// before\nlet content = fetch_skill_file(&raw_url, github_token).await?; // redirect bail surfaces raw anyhow message\n\n// after\nlet content = match fetch_skill_file(&raw_url, github_token).await {\n    Ok(content) => content,\n    Err(err) if err.to_string().contains(\"unexpected redirect\") => {\n        prompt_github_reauth().await?; // token stale or repo moved\n        fetch_skill_file(&raw_url, fresh_token()).await?\n    }\n    Err(err) => return Err(err),\n};","handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the token is valid before fetching the raw file.\nasync fn github_token_is_valid(http_client: &HttpClient, token: &str) -> bool {\n    let Ok(request) = http_client.get(\"https://api.github.com/user\", Default::default()) else {\n        return false;\n    };\n    let request = request.header(\"Authorization\", format!(\"Bearer {token}\"));\n    matches!(http_client.send(request).await, Ok(response) if response.status().is_success())\n}","typeGuard":null,"tryCatchPattern":"match import_skill_from_url(&url, token).await {\n    Err(err) if err.to_string().contains(\"unexpected redirect\") => {\n        // Token stale or repo moved: refresh auth, verify URL, then retry once.\n        reauthenticate_github().await?;\n        import_skill_from_url(&url, fresh_token()).await\n    }\n    result => result,\n}","preventionTips":["Re-authenticate GitHub whenever imports start failing with redirects — stale tokens are the top cause","Open the raw URL in a logged-in browser before importing to confirm it serves content, not a redirect","Copy raw.githubusercontent.com links from the file's Raw button instead of hand-building them"],"tags":["github","http-redirect","authentication","skill-import"],"backgroundTag":"login-redirect","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}