{"record":{"id":"1e7f4ef3727c525d","repo":"chatboxai/chatbox","slug":"report-failed-with-status-response-status","errorCode":null,"errorMessage":"Report failed with status ${response.status}","messagePattern":"Report failed with status (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/services/native-report.ts","lineNumber":27,"sourceCode":"export interface ReportNativeContentOptions {\n  id: string\n  type: string\n  details: string\n  apiOrigin?: string\n  fetchFn?: typeof fetch\n  headers?: Record<string, string>\n}\n\nexport async function reportNativeContent(options: ReportNativeContentOptions): Promise<void> {\n  const fetchFn = options.fetchFn ?? fetch\n  const origin = (options.apiOrigin?.trim() || CHATBOX_DEFAULT_ORIGIN).replace(/\\/+$/, '')\n  const response = await fetchFn(`${origin}/api/report_content`, {\n    method: 'POST',\n    headers: { 'Content-Type': 'application/json', ...options.headers },\n    body: JSON.stringify({ id: options.id, type: options.type, details: options.details }),\n  })\n  if (!response.ok) {\n    throw new Error(`Report failed with status ${response.status}`)\n  }\n}\n","sourceCodeStart":9,"sourceCodeEnd":30,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/shared/services/native-report.ts#L9-L30","documentation":"Thrown by reportNativeContent (src/shared/services/native-report.ts:27) when the POST to {apiOrigin}/api/report_content returns a non-2xx status. The function posts { id, type, details } with an injectable fetchFn and origin (defaulting to the Chatbox origin) and has no body parsing or retry; any HTTP failure surfaces as a bare status code in the message.","triggerScenarios":"fetchFn POST to `${origin}/api/report_content` returns response.ok === false. Common codes: 400 (bad/missing id, type, or details), 401/403 (auth required for the resource being reported), 404 (wrong apiOrigin), 429 (rate limited), 5xx (server). Also fires when apiOrigin is misconfigured to a host that returns a non-2xx for the path.","commonSituations":"User clicks 'Report' on content whose id/type the server no longer recognizes; apiOrigin override points at the wrong environment; report endpoint temporarily down; client hitting rate limits after repeated reports; a missing/blank options.id or options.type rejected by server-side validation.","solutions":["Wrap the call in try/catch and surface a user-facing 'report failed, try again' message; reporting is best-effort and should not block the UI.","Confirm options.apiOrigin (if overridden) is correct; omit it to use the Chatbox default origin.","Validate that options.id, options.type, and options.details are non-empty and of the expected shape before sending.","On 429, back off and let the user retry rather than spamming the endpoint.","Inspect the real status by reproducing the POST with curl against the target origin."],"exampleFix":"// before\nawait reportNativeContent({ id, type, details })\n\n// after\ntry {\n  await reportNativeContent({ id, type, details })\n} catch (e) {\n  toastActions.add((e as Error).message)\n}","handlingStrategy":"try-catch","validationCode":"// Reject incomplete report payloads before the network call\nfunction assertReportInput(o: ReportNativeContentOptions) {\n  if (!o.id) throw new Error('report id is required')\n  if (!o.type) throw new Error('report type is required')\n}","typeGuard":null,"tryCatchPattern":"// Reporting is best-effort; never block the UI on it\ntry {\n  await reportNativeContent({ id, type, details })\n} catch (e) {\n  toastActions.add((e as Error).message || t('Report failed'))\n}","preventionTips":["Treat report submission as fire-and-forget with user-facing failure feedback.","Always pass a concrete apiOrigin or rely on the Chatbox default; do not derive it from user input.","Rate-limit repeated reports client-side to avoid 429.","Pass an AbortSignal tied to view unmount so in-flight reports cancel cleanly."],"tags":["network","api","reporting","http-status"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}