Skip to content

[Bug]: saveResume returns HTTP 200 success with a null resume when resumeId is invalid or not owned by the caller #375

Description

@hariom888

Bug Description

In saveResume (backend/controllers/resumeController.js), the update branch calls Resume.findOneAndUpdate({ _id: resumeId, user: userId }, { title, latexCode }, { new: true }). If no document matches (wrong ID, deleted resume, or resumeId belonging to another user), this resolves to null, but the handler does not check for that before responding with { success: true, resume: null }.

Steps to Reproduce

  1. Authenticate as User A and obtain a valid resumeId belonging to User B (or use a resumeId that no longer exists).
  2. POST to /api/resume/save with { title, latexCode, resumeId } using that resumeId while authenticated as User A.
  3. Inspect the response.

Expected Behavior

The request should fail with a 404 (or 403) and a clear error message indicating the resume was not found or not owned by the caller — no misleading success response.

Actual Behavior

The endpoint returns HTTP 200 with { success: true, resume: null }. The client displays a save-confirmation even though nothing was persisted or updated, silently discarding the user's edits.

Severity

Medium

Screenshots / Screen Recording

No response

Browser

No response

Operating System

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions