srbhr/Resume-Matcher · error · Error
Failed to load prompt config (status ${res.status}).
Error message
Failed to load prompt config (status ${res.status}). What it means
fetchPromptConfig calls GET /config/prompts via apiFetch and throws this Error when the response is not ok (res.ok is false). It is the library's way of surfacing any non-2xx HTTP status from the backend prompt-config endpoint, including the status code in the message. The backend itself decided the request failed (auth, crash, missing endpoint) — this throw only reports it.
Source
Thrown at apps/frontend/lib/api/config.ts:311
label: string;
description: string;
}
export interface PromptConfig {
default_prompt_id: string;
prompt_options: PromptOption[];
}
export interface PromptConfigUpdate {
default_prompt_id?: string;
}
// Fetch prompt configuration
export async function fetchPromptConfig(): Promise<PromptConfig> {
const res = await apiFetch('/config/prompts', { credentials: 'include' });
if (!res.ok) {
throw new Error(`Failed to load prompt config (status ${res.status}).`);
}
return res.json();
}
// Update prompt configuration
export async function updatePromptConfig(update: PromptConfigUpdate): Promise<PromptConfig> {
const res = await apiFetch('/config/prompts', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify(update),
});
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.detail || `Failed to update prompt config (status ${res.status}).`);
}View on GitHub (pinned to 116f9cc3b0)
Solutions
- Check the status code in the message: 401/403 → re-authenticate (log in again so credentials cookie is set); 404 → verify backend exposes /api/v1/config/prompts and next.config.ts rewrites target the right BACKEND_ORIGIN; 500/502/503 → check backend logs / whether the server on :8000 is up.
- Confirm NEXT_PUBLIC_API_URL and BACKEND_ORIGIN env vars match your deployment (default '/' proxied to 127.0.0.1:8000 in dev).
- Curl the endpoint directly (curl -i http://127.0.0.1:8000/api/v1/config/prompts with the session cookie) to isolate frontend proxy vs backend fault.
- Add retry/fallback rendering in the calling UI so a transient 502 does not break the settings page.
Example fix
// before
const res = await apiFetch('/config/prompts', { credentials: 'include' });
if (!res.ok) {
throw new Error(`Failed to load prompt config (status ${res.status}).`);
}
// after
const res = await apiFetch('/config/prompts', { credentials: 'include' });
if (res.status === 401) {
await refreshSession(); // re-login then retry once
}
if (!res.ok) {
throw new Error(`Failed to load prompt config (status ${res.status}).`);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure session exists before calling authenticated config endpoints
const hasSession = document.cookie.includes('session');
if (!hasSession) await ensureLogin(); Type guard
function isPromptConfig(x: unknown): x is PromptConfig {
return typeof x === 'object' && x !== null && 'prompts' in x;
} Try / catch
try {
const cfg = await fetchPromptConfig();
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
if (msg.includes('status 401')) await reLoginAndRetry();
else showConfigError(msg);
} Prevention
- Keep the backend on :8000 running before loading settings pages in dev
- Verify NEXT_PUBLIC_API_URL / BACKEND_ORIGIN per environment
- Monitor session expiry and refresh credentials before authenticated calls
- Add fallback/placeholder rendering when config fetch fails
When it happens
Trigger: Any GET /config/prompts response with a non-2xx status: 401/403 when the session cookie is missing/expired or CSRF fails, 404 when the backend route is absent or the Next.js proxy rewrite to BACKEND_ORIGIN is misconfigured, 500/502/503 when the backend is down or the prompt-config store fails to load, or a 404 from a stale NEXT_PUBLIC_API_URL/BACKEND_ORIGIN pointing at the wrong service.
Common situations: Backend not running on :8000 while frontend dev server proxies /api to it; user session expired so the cookie-authenticated config call 401s; deploying frontend without BACKEND_ORIGIN set so rewrites 502; upgrading the backend and /config/prompts was renamed or removed.
Related errors
- Failed to load feature prompts (status ${res.status}).
- ${data.detail || Failed to update prompt config (status ${re
- ${message = errBody.detail or Failed to update feature promp
- Failed to load API key status (status ${res.status}).
- Failed to load LLM config (status ${res.status}).
AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28).
Data as JSON: /api/errors/64b615ccdd873e2e.
Report an issue: GitHub.