{"record":{"id":"b56433fe78c63bfe","repo":"BerriAI/litellm","slug":"llm-as-a-judge-on-failure-must-be-block-or-log","errorCode":null,"errorMessage":"llm_as_a_judge on_failure must be 'block' or 'log', got '{on_failure}'","messagePattern":"llm_as_a_judge on_failure must be 'block' or 'log', got '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py","lineNumber":255,"sourceCode":"    guardrail_name: Final = guardrail.get(\"guardrail_name\")\n    if not guardrail_name:\n        raise ValueError(\"llm_as_a_judge guardrail requires a guardrail_name\")\n\n    judge_model: Final = _get_litellm_param(litellm_params, guardrail, \"judge_model\")\n    if not judge_model:\n        raise ValueError(\"llm_as_a_judge guardrail requires judge_model in litellm_params\")\n\n    criteria: Final = _get_litellm_param(litellm_params, guardrail, \"criteria\") or []\n    if not criteria:\n        raise ValueError(\"llm_as_a_judge guardrail requires at least one criterion\")\n\n    weight_total: Final = sum(float(c.get(\"weight\", 0)) for c in criteria)\n    if abs(weight_total - 100) > 0.5:\n        raise ValueError(f\"llm_as_a_judge criterion weights must sum to 100 (got {weight_total})\")\n\n    on_failure: Final = _get_litellm_param(litellm_params, guardrail, \"on_failure\", \"block\")\n    if on_failure not in _VALID_ON_FAILURE:\n        raise ValueError(f\"llm_as_a_judge on_failure must be 'block' or 'log', got '{on_failure}'\")\n\n    overall_threshold: Final = float(_get_litellm_param(litellm_params, guardrail, \"overall_threshold\", 80.0))\n\n    mode: Final = _get_litellm_param(litellm_params, guardrail, \"mode\")\n    event_hook: GuardrailEventHooks | None = None\n    if isinstance(mode, str) and mode in {e.value for e in GuardrailEventHooks}:\n        event_hook = GuardrailEventHooks(mode)\n\n    instance: Final = LLMAsAJudgeGuardrail(\n        guardrail_name=guardrail_name,\n        judge_model=judge_model,\n        criteria=criteria,\n        overall_threshold=overall_threshold,\n        on_failure=on_failure,\n        event_hook=event_hook,\n        default_on=bool(_get_litellm_param(litellm_params, guardrail, \"default_on\", False)),\n    )\n    litellm.logging_callback_manager.add_litellm_callback(instance)","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/llm_as_a_judge/__init__.py#L237-L273","documentation":"initialize_guardrail() validates on_failure against the allowed set {'block', 'log'} and raises ValueError with the offending value otherwise. on_failure controls whether a below-threshold judge score blocks the response (HTTP 422) or is merely logged.","triggerScenarios":"A litellm_llm_as_a_judge guardrail with on_failure set to anything except 'block' or 'log' - e.g. 'raise', 'BLOCK' (case-sensitive), 'ignore', or 'warn'.","commonSituations":"Naming borrowed from other guardrails' on_violation vocabularies ('alert'); uppercase values from env-var templating; typos.","solutions":["Set on_failure: 'log' if you want failures recorded without blocking","Set on_failure: 'block' (or omit it - block is the default) to keep the 422 behavior","Check casing and spelling: the value must be lowercase 'block' or 'log'"],"exampleFix":"# before\n litellm_params:\n   on_failure: alert\n\n# after\n litellm_params:\n   on_failure: log","handlingStrategy":"validation","validationCode":"VALID_ON_FAILURE = {\"block\", \"log\"}  \non_failure = litellm_params.get(\"on_failure\", \"block\")  \nassert on_failure in VALID_ON_FAILURE, (  \n    f\"on_failure must be one of {sorted(VALID_ON_FAILURE)}, got {on_failure!r}\"  \n)","typeGuard":"def is_valid_on_failure(v: object) -> bool:  \n    return isinstance(v, str) and v in {\"block\", \"log\"}","tryCatchPattern":null,"preventionTips":["Remember the vocabulary is block/log (lowercase) - not other guardrails' 'alert'","Omit on_failure entirely if you want the default 'block' behavior"],"tags":["llm-as-a-judge","guardrail","config","startup"],"backgroundTag":"config-validation-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}