{"record":{"id":"a4f9b8d2ffefdc8b","repo":"diegosouzapw/OmniRoute","slug":"security-001","errorCode":"SECURITY_001","errorMessage":"Request blocked: potential prompt injection detected","messagePattern":"Request blocked: potential prompt injection detected","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/app/api/v1/chat/completions/route.ts","lineNumber":178,"sourceCode":"        }\n\n        // Resolve model alias before forwarding to handleChat\n        if (parsedBody && typeof parsedBody === \"object\") {\n          await resolveModelAliasWithSeedFallbackOnBody(parsedBody).catch(() => {\n            /* swallow — fall through with original model */\n          });\n        }\n        admission.lease = structuralAdmission.lease;\n\n        const { blocked, result } = injectionGuard(parsedBody);\n        if (blocked) {\n          return finishAdmission(\n            new Response(\n              JSON.stringify({\n                error: {\n                  message: \"Request blocked: potential prompt injection detected\",\n                  type: \"injection_detected\",\n                  code: \"SECURITY_001\",\n                  detections: result.detections.length,\n                },\n              }),\n              { status: 400, headers: { ...CORS_HEADERS, \"Content-Type\": \"application/json\" } }\n            )\n          );\n        }\n      }\n    } catch (error) {\n      console.error(\"[SECURITY] Prompt injection guard failed:\", error);\n    }\n\n    // Gate the early SSE keepalive wrapper: only wrap when the client explicitly\n    // asks for streaming (body `stream: true`) or the Accept header forces SSE.\n    // The parsed body is passed through UNTOUCHED — the actual stream/JSON framing\n    // stays decided by chatCore/resolveStreamFlag (legacy streaming default and the\n    // per-key `streamDefaultMode: \"json\"` opt-in are preserved).\n    const parsedBodyIsRecord = isRecord(parsedBody);","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/app/api/v1/chat/completions/route.ts#L160-L196","documentation":"Error \"Request blocked: potential prompt injection detected\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/app/api/v1/chat/completions/route.ts:178 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"}