{"record":{"id":"85b81943492496a7","repo":"diegosouzapw/OmniRoute","slug":"invalid-json","errorCode":"INVALID_JSON","errorMessage":"Request body is not valid JSON","messagePattern":"Request body is not valid JSON","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/app/api/settings/route.ts","lineNumber":292,"sourceCode":"    return NextResponse.json({ error: \"Failed to load settings\" }, { status: 500 });\n  }\n}\n\nexport async function PATCH(request: Request) {\n  const authError = await requireManagementAuth(request);\n  if (authError) return authError;\n\n  // Derive actor + raw body once so the rejection paths can audit consistently.\n  const actor = await deriveAuditActor(request);\n  let rawBody: Record<string, unknown> = {};\n  try {\n    rawBody = (await request.json()) as Record<string, unknown>;\n  } catch {\n    // Malformed JSON — surface a zod-style failure path so the rejection\n    // is auditable like every other 400.\n    emitSettingsFailureAudit(request, actor, \"INVALID_JSON\", []);\n    return NextResponse.json(\n      { error: { code: \"INVALID_JSON\", message: \"Request body is not valid JSON\" } },\n      { status: 400 }\n    );\n  }\n  const attemptedKeys = attemptedKeysOf(rawBody);\n  const expectedRevision = parseExpectedRevision(request, rawBody);\n\n  try {\n    // Zod validation\n    const validation = validateBody(updateSettingsSchema, rawBody);\n    if (isValidationFailure(validation)) {\n      // Detect spawn-capable prefix rejection (spec AC-8) so the audit row\n      // names the correct error code; otherwise fall back to the generic\n      // validation-failure label.\n      const isBypassPrefixRejection = (validation.error.details || []).some(\n        (d) => typeof d.message === \"string\" && d.message.includes(\"BYPASS_PREFIX_NOT_ALLOWED\")\n      );\n      emitSettingsFailureAudit(\n        request,","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/app/api/settings/route.ts#L274-L310","documentation":"Error \"Request body is not valid JSON\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/app/api/settings/route.ts:292 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}