{"record":{"id":"d7d1cd2c880656e0","repo":"amruthpillai/reactive-resume","slug":"application-document-cannot-be-empty","errorCode":null,"errorMessage":"Application document cannot be empty.","messagePattern":"Application document cannot be empty\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/tools.ts","lineNumber":67,"sourceCode":"\t\t\t\tcontent: [{ type: \"text\", text: `Error ${label}: ${errorMessage(error)}${errorHint(error)}` }],\n\t\t\t};\n\t\t}\n\t};\n}\n\nfunction text(value: string): CallToolResult {\n\treturn { content: [{ type: \"text\", text: value }] };\n}\n\nfunction json(value: unknown): CallToolResult {\n\treturn text(JSON.stringify(value, null, 2));\n}\n\nfunction fileFromBase64(input: { fileName: string; contentType: string; dataBase64: string }): File {\n\tif (input.contentType !== \"application/pdf\") throw new Error(\"Application documents must be PDF files.\");\n\n\tconst bytes = Buffer.from(input.dataBase64, \"base64\");\n\tif (bytes.length === 0) throw new Error(\"Application document cannot be empty.\");\n\n\treturn new File([bytes], input.fileName, { type: input.contentType });\n}\n\nfunction coerceFollowUpAt(input: Record<string, unknown>): Record<string, unknown> {\n\tif (!(\"followUpAt\" in input)) return input;\n\n\tconst followUpAt = input.followUpAt;\n\tif (followUpAt === undefined || followUpAt === null || followUpAt instanceof Date) return input;\n\n\treturn { ...input, followUpAt: new Date(String(followUpAt)) };\n}\n\nfunction buildResumeShareUrl(username: string, slug: string): string {\n\tconst base = env.APP_URL.replace(/\\/$/, \"\");\n\treturn `${base}/${encodeURIComponent(username)}/${encodeURIComponent(slug)}`;\n}\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/amruthpillai/reactive-resume/blob/3a5b12e2a40374a9571988701fcb75c5a1831c42/packages/mcp/src/tools.ts#L49-L85","documentation":"fileFromBase64 decodes the dataBase64 string and throws if the resulting byte length is 0. This guards against empty/blank attachments being registered as valid PDFs (the contentType check at line 64 already passed, so the bytes are the problem).","triggerScenarios":"Passing dataBase64: '' or a string of only whitespace/newlines; a base64 of a truncated/empty file; the caller forgot to attach the file contents.","commonSituations":"Client code that builds the payload but assigns an undefined/empty variable to dataBase64; a file read that returned empty due to a path error; copy-paste of a placeholder payload.","solutions":["Verify the source file is non-empty (fs.stat size > 0) before encoding.","After base64-encoding, assert Buffer.from(b64,'base64').length > 0 before calling the tool.","Strip whitespace padding mistakes and confirm valid base64 alphabet + correct padding."],"exampleFix":"// before\nconst dataBase64 = '';\n// after\nconst buf = await fs.readFile(path); // assert buf.length > 0\nconst dataBase64 = buf.toString('base64');","handlingStrategy":"validation","validationCode":"const buf = Buffer.from(dataBase64, 'base64');\nif (buf.length === 0) throw new TypeError('Attachment is empty; attach the file contents.');","typeGuard":"function hasNonEmptyBytes(b64: string): boolean {\n  return Buffer.from(b64, 'base64').length > 0;\n}","tryCatchPattern":null,"preventionTips":["Read and size-check the file before encoding.","Confirm the base64 string isn't blank or whitespace-only.","Verify correct padding/alphabet."],"tags":["mcp","validation","attachments","base64"],"backgroundTag":null,"analyzedSha":"3a5b12e2a40374a9571988701fcb75c5a1831c42","analyzedAt":"2026-08-12T22:31:22.666Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}