{"record":{"id":"d0fd5961529e7165","repo":"alibaba/arthas","slug":"error","errorCode":null,"errorMessage":"元数据获取失败","messagePattern":"元数据获取失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"labs/arthas-jfr-frontend/src/services/jfr.ts","lineNumber":16,"sourceCode":"\n// 获取JFR文件分析维度元数据\nexport async function fetchJfrMetadata(fileId) {\n  const body = {\n    namespace: 'jfr-file',\n    api: 'metadata',\n    target: fileId,\n    parameters: {}\n  };\n  const res = await fetch('/arthas-api/analysis', {\n    method: 'POST',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify(body)\n  });\n  const json = await res.json();\n  if (json.code !== 1) throw new Error(json.msg || '元数据获取失败');\n  return json;\n}\n\n// 获取火焰图数据\nexport async function fetchJfrFlameGraph({ fileId, dimension, include, taskSet }) {\n  const body = {\n    namespace: 'jfr-file',\n    api: 'flameGraph',\n    target: fileId,\n    parameters: { dimension, include, taskSet }\n  };\n  const res = await fetch('/arthas-api/analysis', {\n    method: 'POST',\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify(body)\n  });\n  const json = await res.json();\n  if (json.code !== 1) throw new Error(json.msg || '火焰图获取失败');","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/labs/arthas-jfr-frontend/src/services/jfr.ts#L1-L34","documentation":"Thrown by fetchJfrMetadata in jfr.ts when POSTing {namespace:'jfr-file', api:'metadata', target:fileId} to /arthas-api/analysis and the response JSON has code !== 1. The message falls back to '元数据获取失败' (metadata fetch failed) only when the server supplied no msg, so the real cause is usually in json.msg or the arthas backend log.","triggerScenarios":"fileId refers to a JFR file that was not uploaded/expired; the arthas analysis backend is unreachable or errored; res.json() succeeded but code is an error code with a server msg.","commonSituations":"Frontend holds a stale fileId after the upload expired; backend arthas service down; the JFR file failed to parse on the server side.","solutions":["Inspect the actual json.msg in the response (it overrides this fallback) and the arthas backend log for the real error.","Re-upload the JFR file and use the freshly returned fileId.","Confirm the /arthas-api/analysis endpoint is reachable and the backend analysis service is running."],"exampleFix":"// before\nconst meta = await fetchJfrMetadata({ fileId });\n\n// after\ntry {\n  const meta = await fetchJfrMetadata({ fileId });\n} catch (e) {\n  console.error('metadata failed for', fileId, e.message);\n  // re-upload then retry with new fileId\n}","handlingStrategy":"try-catch","validationCode":"async function safeFetchMetadata(fileId) {\n  const res = await fetch('/arthas-api/analysis', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ namespace:'jfr-file', api:'metadata', target:fileId, parameters:{} }) });\n  if (!res.ok) throw new Error('HTTP ' + res.status);\n  const json = await res.json();\n  if (json.code !== 1) throw new Error(json.msg || 'metadata failed');\n  return json;\n}","typeGuard":null,"tryCatchPattern":"try { const meta = await fetchJfrMetadata({ fileId }); }\ncatch (e) { showError(e.message); await reuploadJfr(); }","preventionTips":["Validate fileId is fresh before calling.","Surface json.msg to the user instead of the generic fallback.","Check backend connectivity first."],"tags":["network","jfr","fetch","backend"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}