amruthpillai/reactive-resume · error · Error

Application document cannot be empty.

Error message

Application document cannot be empty.

What it means

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).

Source

Thrown at packages/mcp/src/tools.ts:67

				content: [{ type: "text", text: `Error ${label}: ${errorMessage(error)}${errorHint(error)}` }],
			};
		}
	};
}

function text(value: string): CallToolResult {
	return { content: [{ type: "text", text: value }] };
}

function json(value: unknown): CallToolResult {
	return text(JSON.stringify(value, null, 2));
}

function fileFromBase64(input: { fileName: string; contentType: string; dataBase64: string }): File {
	if (input.contentType !== "application/pdf") throw new Error("Application documents must be PDF files.");

	const bytes = Buffer.from(input.dataBase64, "base64");
	if (bytes.length === 0) throw new Error("Application document cannot be empty.");

	return new File([bytes], input.fileName, { type: input.contentType });
}

function coerceFollowUpAt(input: Record<string, unknown>): Record<string, unknown> {
	if (!("followUpAt" in input)) return input;

	const followUpAt = input.followUpAt;
	if (followUpAt === undefined || followUpAt === null || followUpAt instanceof Date) return input;

	return { ...input, followUpAt: new Date(String(followUpAt)) };
}

function buildResumeShareUrl(username: string, slug: string): string {
	const base = env.APP_URL.replace(/\/$/, "");
	return `${base}/${encodeURIComponent(username)}/${encodeURIComponent(slug)}`;
}

View on GitHub (pinned to 3a5b12e2a4)

Solutions

  1. Verify the source file is non-empty (fs.stat size > 0) before encoding.
  2. After base64-encoding, assert Buffer.from(b64,'base64').length > 0 before calling the tool.
  3. Strip whitespace padding mistakes and confirm valid base64 alphabet + correct padding.

Example fix

// before
const dataBase64 = '';
// after
const buf = await fs.readFile(path); // assert buf.length > 0
const dataBase64 = buf.toString('base64');
Defensive patterns

Strategy: validation

Validate before calling

const buf = Buffer.from(dataBase64, 'base64');
if (buf.length === 0) throw new TypeError('Attachment is empty; attach the file contents.');

Type guard

function hasNonEmptyBytes(b64: string): boolean {
  return Buffer.from(b64, 'base64').length > 0;
}

Prevention

When it happens

Trigger: Passing dataBase64: '' or a string of only whitespace/newlines; a base64 of a truncated/empty file; the caller forgot to attach the file contents.

Common situations: 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.

Related errors


AI-assisted analysis of amruthpillai/reactive-resume@3a5b12e2a4 (2026-08-12). Data as JSON: /api/errors/d7d1cd2c880656e0. Report an issue: GitHub.