Description
Re-summarizing a PDF that's already cached crashes with a 500: the cache-hit branch reads buffer.length after buffer has been set to null.
backend/controllers/notesSummaryController.js (~L145-156):
const fileSize = buffer.length; // L145 — correct, captured before nulling
const base64Data = buffer.toString("base64");
buffer = null; // L147 — memory released
const existingSummary = await NotesSummary.findOne({ contentHash });
if (existingSummary) {
return res.status(200).json({
...
fileSize: buffer.length, // L156 — TypeError: Cannot read properties of null (reading 'length')
Steps to Reproduce
Summarize any PDF whose contentHash already has a saved NotesSummary (i.e. anyone previously summarized that exact file) via POST /api/notes-summary/summarize. Execution enters the cache-hit branch and hits buffer.length on L156 → TypeError → caught by the outer handler → 500 "Failed to summarize notes." So the dedup/cache optimization breaks summarization for a perfectly valid PDF.
Root cause
When buffer = null (memory release) was introduced, the cache-hit branch wasn't updated. The non-cache success path (L234) already correctly uses the fileSize const.
Fix
Line 156 → fileSize, (use the const captured at L145) instead of fileSize: buffer.length.
Happy to fix if assigned.
Contributing as part of Elite Coders Summer of Code (ECSoC 2026).
Description
Re-summarizing a PDF that's already cached crashes with a 500: the cache-hit branch reads
buffer.lengthafterbufferhas been set tonull.backend/controllers/notesSummaryController.js(~L145-156):Steps to Reproduce
Summarize any PDF whose
contentHashalready has a savedNotesSummary(i.e. anyone previously summarized that exact file) viaPOST /api/notes-summary/summarize. Execution enters the cache-hit branch and hitsbuffer.lengthonL156→TypeError→ caught by the outer handler → 500 "Failed to summarize notes." So the dedup/cache optimization breaks summarization for a perfectly valid PDF.Root cause
When
buffer = null(memory release) was introduced, the cache-hit branch wasn't updated. The non-cache success path (L234) already correctly uses thefileSizeconst.Fix
Line 156 →
fileSize,(use the const captured at L145) instead offileSize: buffer.length.Happy to fix if assigned.
Contributing as part of Elite Coders Summer of Code (ECSoC 2026).