linshenkx/prompt-optimizer · error · Error
${context}: ${response.status} ${message || response.statusT
Error message
${context}: ${response.status} ${message || response.statusText} What it means
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.
Source
Thrown at packages/ui/src/utils/remote-backup.ts:539
export const saveRemoteBackupSettings = (settings: RemoteBackupSettings): void => {
if (typeof window === 'undefined') return
window.localStorage.setItem(REMOTE_BACKUP_SETTINGS_KEY, JSON.stringify(rememberRemoteBackupProvider(settings)))
}
const appendStep = (
steps: RemoteBackupDetectionStep[],
key: RemoteBackupDetectionStep['key'],
ok: boolean,
message?: string,
) => {
steps.push({ key, ok, ...(message ? { message } : {}) })
}
const assertOkResponse = async (response: Response, context: string): Promise<Response> => {
if (response.ok) return response
const message = await response.text().catch(() => response.statusText)
throw new Error(`${context}: ${response.status} ${message || response.statusText}`)
}
const sleep = (ms: number): Promise<void> =>
new Promise((resolve) => setTimeout(resolve, ms))
const isRetryableHttpStatus = (status: number): boolean =>
status === 408 || status === 425 || status === 429 || status >= 500
const isRetryableFetchError = (error: unknown): boolean => {
const message = String((error as Error)?.message || error)
return error instanceof TypeError ||
/ERR_QUIC_PROTOCOL_ERROR|Failed to fetch|NetworkError|Load failed/i.test(message)
}
const fetchGoogleDriveDownloadWithRetry = async (
url: string,
init: RequestInit,
context: string,View on GitHub (pinned to 3e677b1d9f)
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
Defensive patterns
Strategy: retry
Try / catch
try {
await remoteBackupOperation(...)
} catch (error) {
const msg = (error as Error).message // 'context: status bodyText'
const status = Number(msg.split(':')[1]?.trim().split(' ')[0])
if (status === 401 || status === 403) await refreshCredentials()
else if (status === 429 || status >= 500) await retryLater()
else throw error
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: OAuth token expired mid-session; Drive quota exceeded; rate limiting from frequent backup syncs; backup manifest referencing a file deleted in the cloud console.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- ${context}: ${(error as Error).message || String(error)}
- ${context}: ${(lastError as Error)?.message || String(lastEr
- Google Drive object not found: ${path}
- Anthropic API error (${error.status}): ${error.message}
- Cloudflare model search failed: ${await this.getErrorMessage
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/4c9ee26be3dc73ad.
Report an issue: GitHub.