srbhr/Resume-Matcher · error · Error
Failed to generate interview preparation (status ${res.statu
Error message
Failed to generate interview preparation (status ${res.status}): ${text} What it means
generateInterviewPrep calls POST /resumes/{id}/generate-interview-prep and throws this Error for any non-OK backend status, including the response body text in the message. It exists to surface server-side interview-prep generation failures as a typed exception rather than silently parsing bad JSON.
Source
Thrown at apps/frontend/lib/api/resume.ts:369
}
/** Generates an outreach message on-demand for a tailored resume */
export async function generateOutreachMessage(resumeId: string): Promise<string> {
const res = await apiPost(`/resumes/${encodeURIComponent(resumeId)}/generate-outreach`, {});
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new Error(`Failed to generate outreach message (status ${res.status}): ${text}`);
}
const data = await res.json();
return data.content;
}
/** Generates interview preparation on-demand for a tailored resume */
export async function generateInterviewPrep(resumeId: string): Promise<InterviewPrepData> {
const res = await apiPost(`/resumes/${encodeURIComponent(resumeId)}/generate-interview-prep`, {});
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new Error(`Failed to generate interview preparation (status ${res.status}): ${text}`);
}
const data = (await res.json()) as { interview_prep: InterviewPrepData };
return data.interview_prep;
}
/** Retries AI processing for a failed resume */
export async function retryProcessing(resumeId: string): Promise<ResumeUploadResponse> {
const res = await apiPost(`/resumes/${encodeURIComponent(resumeId)}/retry-processing`, {});
if (!res.ok) {
const text = await res.text().catch(() => '');
throw new Error(`Failed to retry processing (status ${res.status}): ${text}`);
}
return res.json();
}
/** Fetches the job description used to tailor a resume */
export async function fetchJobDescription(
resumeId: stringView on GitHub (pinned to 116f9cc3b0)
Solutions
- Read the status and text in the message for the server-side cause
- Confirm the resume status is 'completed' before requesting interview prep
- Re-login if status is 401/403
- Retry after a delay for 5xx (AI provider load) or use the retry-processing endpoint if the resume is in a failed state
- Verify the resumeId is valid and current
Example fix
// before
const prep = await generateInterviewPrep(resumeId);
// after
try {
const prep = await generateInterviewPrep(resumeId);
} catch (e) {
setPrepError('Interview prep is unavailable for this resume. Ensure processing completed, then retry.');
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!resumeId) throw new Error('resumeId is required');
const status = await getResumeStatus(resumeId);
if (status.state !== 'completed') {
throw new Error(`Interview prep requires a completed resume (state: ${status.state})`);
} Type guard
function isInterviewPrepData(v: unknown): v is InterviewPrepData {
return typeof v === 'object' && v !== null && !Array.isArray(v);
} Try / catch
try {
const prep = await generateInterviewPrep(resumeId);
render(prep);
} catch (e) {
if (e instanceof Error && /status 5\d\d/.test(e.message)) {
scheduleRetryWithBackoff();
} else {
showError('Interview prep unavailable. Ensure the resume finished processing.');
}
} Prevention
- Only request interview prep after AI processing succeeds
- Check resume state via the status endpoint before generating
- Distinguish retryable (5xx) from permanent (4xx) failures by the status in the message
- Handle session expiry centrally (401 interceptor)
- Cache successful prep results to reduce repeat generation calls
When it happens
Trigger: Non-2xx from the generate-interview-prep endpoint: resume not found (404), failed/incomplete AI analysis (500/502/504), expired auth (401), or malformed resumeId (400 validation).
Common situations: Seen when interview prep is requested for a resume whose AI processing failed, when the LLM upstream times out producing the structured interview_prep data, after session expiry, or when testing with a hardcoded id that no longer exists.
Related errors
- Failed to generate outreach message (status ${res.status}):
- Failed to fetch job description (status ${res.status}): ${te
- Failed to retry processing (status ${res.status}): ${text}
- ${fallback} (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/0ce1850e11bbd889.
Report an issue: GitHub.