{"record":{"id":"4c9ee26be3dc73ad","repo":"linshenkx/prompt-optimizer","slug":"context-response-status-message-respon","errorCode":null,"errorMessage":"${context}: ${response.status} ${message || response.statusText}","messagePattern":"\\$\\{context\\}: \\$\\{response\\.status\\} \\$\\{message \\|\\| response\\.statusText\\}","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/utils/remote-backup.ts","lineNumber":539,"sourceCode":"\nexport const saveRemoteBackupSettings = (settings: RemoteBackupSettings): void => {\n  if (typeof window === 'undefined') return\n  window.localStorage.setItem(REMOTE_BACKUP_SETTINGS_KEY, JSON.stringify(rememberRemoteBackupProvider(settings)))\n}\n\nconst appendStep = (\n  steps: RemoteBackupDetectionStep[],\n  key: RemoteBackupDetectionStep['key'],\n  ok: boolean,\n  message?: string,\n) => {\n  steps.push({ key, ok, ...(message ? { message } : {}) })\n}\n\nconst assertOkResponse = async (response: Response, context: string): Promise<Response> => {\n  if (response.ok) return response\n  const message = await response.text().catch(() => response.statusText)\n  throw new Error(`${context}: ${response.status} ${message || response.statusText}`)\n}\n\nconst sleep = (ms: number): Promise<void> =>\n  new Promise((resolve) => setTimeout(resolve, ms))\n\nconst isRetryableHttpStatus = (status: number): boolean =>\n  status === 408 || status === 425 || status === 429 || status >= 500\n\nconst isRetryableFetchError = (error: unknown): boolean => {\n  const message = String((error as Error)?.message || error)\n  return error instanceof TypeError ||\n    /ERR_QUIC_PROTOCOL_ERROR|Failed to fetch|NetworkError|Load failed/i.test(message)\n}\n\nconst fetchGoogleDriveDownloadWithRetry = async (\n  url: string,\n  init: RequestInit,\n  context: string,","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/utils/remote-backup.ts#L521-L557","documentation":"Thrown by assertOkResponse in the remote-backup module when an HTTP response for a backup operation (upload, list, metadata) has response.ok === false. The response body text is read (falling back to statusText) and combined with the context label and status code into one message.","triggerScenarios":"Any Google Drive/S3 backup REST call returning 4xx/5xx: 401/403 expired access token or missing scope, 404 deleted backup id, 409 path conflict, 429 quota/rate limit, 5xx service errors; used as the terminal throw when a response is non-retryable or retries are exhausted in download paths.","commonSituations":"OAuth token expired mid-session; Drive quota exceeded; rate limiting from frequent backup syncs; backup manifest referencing a file deleted in the cloud console.","solutions":["Map the status: 401/403 refresh credentials/token; 404 verify the backup id/path exists; 429 back off and retry; 5xx retry later","Read the message body text included in the error for the provider-specific reason (e.g. Google Drive JSON error)","Refresh the auth token and retry the operation","Reduce sync frequency or implement exponential backoff for 429s"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await remoteBackupOperation(...)\n} catch (error) {\n  const msg = (error as Error).message // 'context: status bodyText'\n  const status = Number(msg.split(':')[1]?.trim().split(' ')[0])\n  if (status === 401 || status === 403) await refreshCredentials()\n  else if (status === 429 || status >= 500) await retryLater()\n  else throw error\n}","preventionTips":["Refresh auth tokens proactively before expiry","Parse the context prefix to route errors to the right recovery path","Keep the provider error body in user-facing logs for diagnosis"],"tags":["remote-backup","http-status","google-drive","s3"],"backgroundTag":"http-request-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}