{"record":{"id":"2cdc94e760473ad6","repo":"diegosouzapw/OmniRoute","slug":"paid-model-target-blocked","errorCode":"PAID_MODEL_TARGET_BLOCKED","errorMessage":"This field cannot target a paid-only model while 'Hide paid models' is enabled.","messagePattern":"This field cannot target a paid-only model while 'Hide paid models' is enabled\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/app/api/settings/background-degradation/route.ts","lineNumber":79,"sourceCode":"          details: [{ field: \"body\", message: \"Invalid JSON body\" }],\n        },\n      },\n      { status: 400 }\n    );\n  }\n\n  try {\n    const validation = validateBody(jsonObjectSchema, rawBody);\n    if (isValidationFailure(validation)) {\n      return NextResponse.json({ error: validation.error }, { status: 400 });\n    }\n    const config = validation.data as { degradationMap?: Record<string, string> };\n\n    if (await hasBlockedPaidTarget(config.degradationMap)) {\n      return NextResponse.json(\n        {\n          error: {\n            code: \"PAID_MODEL_TARGET_BLOCKED\",\n            message:\n              \"This field cannot target a paid-only model while 'Hide paid models' is enabled.\",\n          },\n        },\n        { status: 400 }\n      );\n    }\n\n    setBackgroundDegradationConfig(config);\n\n    // Persist to database (excluding stats)\n    const { stats, ...persistable } = getBackgroundDegradationConfig();\n    await updateSettings({ backgroundDegradation: persistable });\n\n    return NextResponse.json({ success: true, ...getBackgroundDegradationConfig() });\n  } catch (error) {\n    console.error(\"[API ERROR] /api/settings/background-degradation PUT:\", error);\n    return NextResponse.json({ error: \"Failed to update config\" }, { status: 500 });","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/app/api/settings/background-degradation/route.ts#L61-L97","documentation":"Business-rule rejection on the background-degradation settings route (#6540): the submitted degradationMap maps a field to a model positively identified as paid-only in the catalog while hidePaidModels is enabled. The route blocks the write with PAID_MODEL_TARGET_BLOCKED (fails open on unknown names).","triggerScenarios":"Thrown at src/app/api/settings/background-degradation/route.ts:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a free-tier degradation target model","Disable 'Hide paid models' in settings if paid targets are intended","Verify the model name/alias resolves to the tier you expect"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}