diegosouzapw/OmniRoute · error
Invalid JSON body
Error message
Invalid JSON body
What it means
Error "Invalid JSON body" thrown in diegosouzapw/OmniRoute.
Source
Thrown at src/app/api/v1/images/generations/route.ts:105
// would silently drop entries if a wider helper were reused for headers
// that can legitimately repeat (e.g., set-cookie).
const PUBLIC_BASE_URL_HEADER_KEYS = ["host", "x-forwarded-host", "x-forwarded-proto"] as const;
function publicBaseUrlHeaders(headers: Headers): Record<string, string> {
const out: Record<string, string> = {};
for (const key of PUBLIC_BASE_URL_HEADER_KEYS) {
const value = headers.get(key);
if (value !== null) out[key] = value;
}
return out;
}
async function postHandler(request, context) {
let rawBody;
try {
rawBody = await request.json();
} catch {
log.warn("IMAGE", "Invalid JSON body");
return errorResponse(HTTP_STATUS.BAD_REQUEST, "Invalid JSON body");
}
const validation = validateBody(v1ImageGenerationSchema, rawBody);
if (isValidationFailure(validation)) {
return errorResponse(HTTP_STATUS.BAD_REQUEST, validation.error.message);
}
const body = validation.data;
const startTime = Date.now();
// Authenticate before policy enforcement. Policy checks intentionally allow
// keyless local mode and assume the route has already rejected invalid keys.
const authRejection = await enforceClientApiRouteAuth(request);
if (authRejection) return authRejection;
// Enforce API key policies (model restrictions + budget limits)
const policy = await enforceApiKeyPolicy(request, body.model);
if (policy.rejection) return policy.rejection;View on GitHub (pinned to a179ffed5b)
When it happens
Trigger: Thrown at src/app/api/v1/images/generations/route.ts:105 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/bfd927747786ed5d.
Report an issue: GitHub.