Problem
src/routes/api/ogimg/+server.ts casts the type query parameter to keyof typeof IMAGE_SIZE without validating it:
const type = (url.searchParams.get('type') || 'opengraph') as keyof typeof IMAGE_SIZE;
A request such as /api/ogimg?type=bad makes IMAGE_SIZE[type] undefined. The endpoint then dereferences .upscale, .width, and .height, causing a runtime error.
Impact
Malformed requests can return a 500 from the OG image endpoint.
Expected
Unknown type values should either fall back to opengraph or return a controlled 400 response.
Suggested Fix
Validate type against IMAGE_SIZE before using it.
Problem
src/routes/api/ogimg/+server.tscasts thetypequery parameter tokeyof typeof IMAGE_SIZEwithout validating it:A request such as
/api/ogimg?type=badmakesIMAGE_SIZE[type]undefined. The endpoint then dereferences.upscale,.width, and.height, causing a runtime error.Impact
Malformed requests can return a 500 from the OG image endpoint.
Expected
Unknown
typevalues should either fall back toopengraphor return a controlled 400 response.Suggested Fix
Validate
typeagainstIMAGE_SIZEbefore using it.