QuantumNous/new-api · warning · Error
API returned error
Error message
API returned error
What it means
Thrown by fetchSystemConfig in use-system-config when /api/status answered HTTP 200 but the JSON envelope has success:false. This means the Go backend itself reported an operational failure (its unified response wrapper), not a transport problem. The app falls back to default system name/logo/flags.
Source
Thrown at web/src/hooks/use-system-config.ts:111
}
return {
systemName: data.system_name || DEFAULT_SYSTEM_NAME,
logo: data.logo || DEFAULT_LOGO,
footerHtml: data.footer_html,
demoSiteEnabled: data.demo_site_enabled,
displayTokenStatEnabled: data.display_token_stat_enabled,
currency,
}
}
// Fetch system config from API
async function fetchSystemConfig(): Promise<Partial<SystemConfig>> {
const response = await fetch('/api/status')
if (!response.ok) throw new Error('Failed to fetch status')
const data: StatusApiResponse = await response.json()
if (!data.success) throw new Error('API returned error')
return mapStatusDataToConfig(data.data)
}
// Preload image and return cleanup function
function preloadImage(
src: string,
onLoad: () => void,
onError: () => void
): () => void {
const img = new Image()
img.onload = onLoad
img.onerror = onError
img.src = src
return () => {
img.onload = null
img.onerror = nullView on GitHub (pinned to e2c7aa7b10)
Solutions
- curl the /api/status endpoint and read the envelope's message field — the code drops it; capture it to find the backend cause.
- Check backend (new-api Go) logs for the error returned by the status controller.
- Fix the underlying backend issue (DB/Redis connectivity, options table) and reload.
- Consider surfacing response message in the thrown error to speed future diagnosis.
Example fix
// before
const data: StatusApiResponse = await response.json()
if (!data.success) throw new Error('API returned error')
// after
const data: StatusApiResponse = await response.json()
if (!data.success) throw new Error(data.message || 'API returned error') Defensive patterns
Strategy: fallback
Type guard
function isStatusSuccess(data: unknown): data is { success: true; data: StatusApiResponse['data'] } {
return typeof data === 'object' && data !== null && (data as any).success === true
} Try / catch
try {
const config = await fetchSystemConfig()
} catch (error) {
// both 'Failed to fetch status' and 'API returned error' map to default config;
// log error and continue — never block app boot on status
} Prevention
- Monitor backend health so /api/status does not fail operationally
- Surface data.message from the envelope in dev builds to speed root-cause
When it happens
Trigger: GET /api/status returns 200 with {success:false,...}: backend panic recovered into an error envelope, maintenance mode, or an internal error computing status data (e.g. options/cache failure).
Common situations: Backend started with a broken database/Redis connection so status assembly fails; a plugin/option load error; deployment where the status handler depends on an uninitialized subsystem.
Related errors
AI-assisted analysis of QuantumNous/new-api@e2c7aa7b10 (2026-08-15).
Data as JSON: /api/errors/6a6d0fbf75161ed6.
Report an issue: GitHub.