Skip to content

bug: Public mentors page returns 500 when a mentor has no mentee_section (unguarded NPE) #753

Description

@yingliu-data

Bug Report

The public mentors page throws HTTP 500 if any mentor row lacks a mentee_section; the keyword filter has the same unguarded dereference.

  • domain/platform/mentorship/Mentor.java:166mentor.getMenteeSection().toDto() with no null check.
  • utils/FiltersUtil.java:79mentor.getMenteeSection().additional() unguarded (while matchesTypes at line 91 explicitly guards null).
  • repository/postgres/component/MentorMapper.java:55-56 only sets menteeSection when a row exists, so null is a reachable state (legacy/partial data).

Reproduction

One mentor exists without a mentee_section row → GET /api/cms/v1/mentorship/mentors throws NPE in Mentor.toDto() → unhandled 500 for the entire public mentors page.

Severity

Medium

Potential Risk

  • A single malformed mentor record takes down the whole public mentors listing.

Suggested Fix

  • Null-guard getMenteeSection() in Mentor.toDto() and in FiltersUtil (mirror the guard already present in matchesTypes).
  • Optionally enforce presence of mentee_section at write time so the null state can't arise.
  • Add a test rendering a mentor with a null mentee section (expect the list to render, not 500).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingepic-mentorshipAll tasks related to mentorship pages & tasksjava/springbootTasks where is needed Java experience or Spring Boot Experience

    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