safer runtime assertion

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Shaheer Sarfaraz 2026-01-19 19:45:26 +00:00 committed by GitHub
parent 5bd57c1b9f
commit 1b927a13be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -470,7 +470,13 @@ apiRouter.patch('/settings', async (req: Request, res: Response) => {
if (resumeProjects === null) {
await settingsRepo.setSetting('resumeProjects', null);
} else {
const profile = (await loadResumeProfile()) as Record<string, unknown>;
const rawProfile = await loadResumeProfile();
if (rawProfile === null || typeof rawProfile !== 'object' || Array.isArray(rawProfile)) {
throw new Error('Invalid resume profile format: expected a non-null object');
}
const profile = rawProfile as Record<string, unknown>;
const { catalog } = extractProjectsFromProfile(profile);
const allowed = new Set(catalog.map((p) => p.id));
const normalized = normalizeResumeProjectsSettings(resumeProjects, allowed);