{"record":{"id":"927924e231c358b5","repo":"openzipkin/zipkin","slug":"failed-to-fetch-trace-from-backend","errorCode":null,"errorMessage":"Failed to fetch trace from backend","messagePattern":"Failed to fetch trace from backend","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"zipkin-lens/src/components/TracePage/Header/HeaderMenu.tsx","lineNumber":63,"sourceCode":"    : undefined;\n\n  const handleMenuButtonClick = (\n    event: React.MouseEvent<HTMLButtonElement>,\n  ) => {\n    setAnchorEl(event.currentTarget);\n  };\n\n  const handleMenuClose = () => {\n    setAnchorEl(null);\n  };\n\n  const handleArchiveButtonClick = useCallback(() => {\n    // We don't store the raw json in the browser yet, so we need to make an\n    // HTTP call to retrieve it again.\n    fetch(`${api.TRACE}/${trace.traceId}`)\n      .then((response) => {\n        if (!response.ok) {\n          throw new Error('Failed to fetch trace from backend');\n        }\n        return response.json();\n      })\n      .then((json) => {\n        // Add zipkin.archived tag to root span\n        /* eslint-disable-next-line no-restricted-syntax */\n        for (const span of json) {\n          if ('parentId' in span === false) {\n            const tags = span.tags || {};\n            tags['zipkin.archived'] = 'true';\n            span.tags = tags;\n            break;\n          }\n        }\n        return json;\n      })\n      .then((json) => {\n        return fetch(archivePostUrl, {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-lens/src/components/TracePage/Header/HeaderMenu.tsx#L45-L81","documentation":"Thrown in zipkin-lens's TracePage HeaderMenu when the browser fetch of the raw trace JSON (GET /api/v2/trace/{traceId}) returns a non-OK HTTP status. The archive flow needs the raw JSON from the backend because it is not cached in the browser, so a failed fetch aborts archiving with this error.","triggerScenarios":"Clicking 'Archive Trace' in the Lens UI when the trace has been dropped from storage (e.g. past the retention/lookback window) and the API returns 404; the Zipkin server or proxy in front of it returns 401/403/500; a misconfigured base URL so the request 404s; transient network failure making response.ok false.","commonSituations":"Trying to archive an old trace that storage (in-memory, MySQL, ES with TTL) already evicted; running Lens against a reverse proxy that blocks or rewrites /api routes; server restart with in-memory storage wiping all traces.","solutions":["Verify the trace still exists: open it in the UI or curl GET /api/v2/trace/{traceId} and expect 200","If it returns 404, the trace expired from storage — re-produce the trace or increase storage retention","Check server/proxy logs and the browser network tab for 401/403/5xx and fix routing or auth for the /api path","Retry after transient backend errors; fetch again before re-clicking Archive"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// check the trace still exists before offering/attempting archive\nconst res = await fetch(`${api.TRACE}/${trace.traceId}`);\nif (!res.ok) {\n  // 404 => trace evicted from storage; 5xx => backend issue\n  throw new Error(`Trace not available (HTTP ${res.status})`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const response = await fetch(`${api.TRACE}/${trace.traceId}`);\n  if (!response.ok) throw new Error(`Fetch trace failed (HTTP ${response.status})`);\n  const json = await response.json();\n} catch (err) {\n  // 404 is permanent (retention); 5xx/network may be transient -> one retry max\n  if (isTransient(err)) await retryOnce();\n  else showUserError('Trace no longer available in the backend');\n}","preventionTips":["Disable/hide the Archive button for traces older than the storage retention window","Surface the HTTP status in the alert so users can distinguish 404 from backend failure","Keep the Lens base URL and proxy config pointing at a reachable Zipkin server"],"tags":["typescript","zipkin-lens","network","http","archive","retention"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}