srbhr/Resume-Matcher · error · HTTPException

Job not found

Error message

Job not found

What it means

A 404 from GET /jobs/{job_id} when no job with that ID exists in the database. get_job simply forwards db.get_job's result; a falsy result (None) becomes 404. Also surfaces indirectly via callers like cover-letter and improve-resume endpoints that depend on a valid job_id.

Source

Thrown at apps/backend/app/routers/jobs.py:48

        job_ids.append(job["job_id"])

    return JobUploadResponse(
        message="data successfully processed",
        job_id=job_ids,
        request={
            "job_descriptions": request.job_descriptions,
            "resume_id": request.resume_id,
        },
    )


@router.get("/{job_id}")
async def get_job(job_id: str) -> dict:
    """Get job description by ID."""
    job = await db.get_job(job_id)

    if not job:
        raise HTTPException(status_code=404, detail="Job not found")

    return job

View on GitHub (pinned to 116f9cc3b0)

Solutions

  1. Verify the job_id exists (list jobs or check the DB) before calling the endpoint
  2. Re-upload the job description to obtain a fresh job_id if the record was deleted
  3. Confirm you are pointing at the correct environment/database
  4. Log the failing job_id and fix the client source that produced it

Example fix

// before
const job = await api.get(`/jobs/${jobId}`);
// after
const res = await api.get(`/jobs/${jobId}`).catch(e =>
  e.response?.status === 404 ? null : Promise.reject(e));
if (!res) {
  const created = await uploadJob(text);
  job = created;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the ID exists before dependent calls
const exists = await api.get(`/jobs/${jobId}`).then(() => true).catch(e => e.response?.status === 404 ? false : Promise.reject(e));
if (!exists) throw new Error(`Job ${jobId} does not exist`);

Type guard

function isValidJobId(id) {
  return typeof id === 'string' && id.trim().length > 0; // plus UUID check if applicable
}
const isUuid = id => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id);

Try / catch

try {
  job = await api.get(`/jobs/${jobId}`);
} catch (e) {
  if (e.response?.status === 404) {
    job = await createJobFromText(savedText); // re-upload to obtain a fresh job_id
  } else throw e;
}

Prevention

When it happens

Trigger: Requesting a job_id that was never created, was deleted, or contains a typo; using a job_id from another environment/database; passing an expired ID after DB cleanup.

Common situations: Client cached a job_id whose record was purged; copying an ID from staging into a production call; truncating the jobs table during development and reusing old IDs.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28). Data as JSON: /api/errors/9e7ebbbd9dd0af2d. Report an issue: GitHub.