{"record":{"id":"2550972f93c37cec","repo":"openzipkin/zipkin","slug":"failed-to-archive-the-trace","errorCode":null,"errorMessage":"Failed to archive the trace","messagePattern":"Failed to archive the trace","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"zipkin-lens/src/components/TracePage/Header/HeaderMenu.tsx","lineNumber":94,"sourceCode":"          }\n        }\n        return json;\n      })\n      .then((json) => {\n        return fetch(archivePostUrl, {\n          method: 'POST',\n          headers: {\n            'Content-Type': 'application/json',\n          },\n          body: JSON.stringify(json),\n        });\n      })\n      .then((response) => {\n        if (\n          !response.ok ||\n          (response.status !== 202 && response.status === 200)\n        ) {\n          throw new Error('Failed to archive the trace');\n        }\n        if (archiveUrl) {\n          dispatch(\n            setAlert({\n              message: `Archive successful! This trace is now accessible at ${archiveUrl}`,\n              severity: 'success',\n            }),\n          );\n        } else {\n          dispatch(\n            setAlert({\n              message: `Archive successful!`,\n              severity: 'success',\n            }),\n          );\n        }\n      })\n      .catch(() => {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin-lens/src/components/TracePage/Header/HeaderMenu.tsx#L76-L112","documentation":"Thrown in zipkin-lens's HeaderMenu archive flow when the POST of the annotated trace JSON to the archive endpoint does not yield an acceptable status. Note the guard is written as !response.ok || (status !== 202 && status === 200): any HTTP 200 (ok) response is rejected because the code demands 202 Accepted, so an archive backend that answers 200 both works and still surfaces this error — a client-side condition bug on top of genuine failures.","triggerScenarios":"POSTing to the configured archive endpoint when it returns 4xx/5xx (misconfigured URL, auth required, CORS blocked); the archive server responding 200 OK instead of 202 Accepted, which this code incorrectly treats as failure; network error before the response arrives.","commonSituations":"Self-hosted archive service (e.g. a custom trace-archive API) that returns 200 rather than 202; archiveUrl env/config pointing at the wrong path; reverse proxy stripping CORS headers so the browser flags the response; auth token missing and endpoint answering 401.","solutions":["If you control the archive endpoint, return 202 Accepted for successful archival so the existing check passes","Check the browser network tab for the POST's real status: 4xx/5xx means config/auth/CORS — fix URL, headers, or proxy","If the endpoint legitimately returns 200, patch the condition to accept success statuses: !response.ok alone (drop the (status !== 202 && status === 200) clause, or explicitly allow 200 and 202)"],"exampleFix":"// before\nif (!response.ok || (response.status !== 202 && response.status === 200)) {\n  throw new Error('Failed to archive the trace');\n}\n\n// after\nif (!response.ok) {\n  throw new Error(`Failed to archive the trace (HTTP ${response.status})`);\n}","handlingStrategy":"try-catch","validationCode":"// pre-flight the archive endpoint configuration before the archive attempt\nif (!archiveUrl) {\n  throw new Error('Archive endpoint is not configured');\n}","typeGuard":null,"tryCatchPattern":".then((response) => {\n  if (!response.ok) {\n    // include the real status; accept 200 and 202 as success\n    throw new Error(`Failed to archive the trace (HTTP ${response.status})`);\n  }\n})\n.catch((err) => {\n  dispatch(setAlert({ message: err.message, severity: 'error' }));\n});","preventionTips":["Make the archive service return 202 Accepted to match the client's expectation","Accept both 200 and 202 in the client check (or rely on response.ok alone)","Verify archive endpoint URL, auth headers, and CORS settings before enabling the archive button","Include the HTTP status in thrown errors to speed up diagnosis"],"tags":["typescript","zipkin-lens","http","archive","status-code","bug"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}