{"record":{"id":"7cc70facb83f6745","repo":"run-llama/llama_index","slug":"unsupported-pydantic-program-mode-pydantic-progr","errorCode":null,"errorMessage":"Unsupported pydantic program mode: {pydantic_program_mode}","messagePattern":"Unsupported pydantic program mode: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/program/utils.py","lineNumber":135,"sourceCode":"    elif pydantic_program_mode == PydanticProgramMode.LM_FORMAT_ENFORCER:\n        try:\n            from llama_index.program.lmformatenforcer import (\n                LMFormatEnforcerPydanticProgram,\n            )  # pants: no-infer-dep\n        except ImportError:\n            raise ImportError(\n                \"This mode requires the `llama-index-program-lmformatenforcer package. Please\"\n                \" install it by running `pip install llama-index-program-lmformatenforcer`.\"\n            )\n\n        return LMFormatEnforcerPydanticProgram.from_defaults(\n            output_cls=output_cls,\n            llm=llm,\n            prompt=prompt,\n            **kwargs,\n        )\n    else:\n        raise ValueError(f\"Unsupported pydantic program mode: {pydantic_program_mode}\")\n\n\ndef _repair_incomplete_json(json_str: str) -> str:\n    \"\"\"\n    Attempt to repair incomplete JSON strings.\n\n    Args:\n        json_str (str): Potentially incomplete JSON string\n\n    Returns:\n        str: Repaired JSON string\n\n    \"\"\"\n    if not json_str.strip():\n        return \"{}\"\n\n    # Add missing quotes\n    quote_count = json_str.count('\"')","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/program/utils.py#L117-L153","documentation":"get_program_for_pydantic_model dispatches on the PydanticProgramMode enum. Any value not handled by the if/elif chain (i.e. not the default or LM_FORMAT_ENFORCER modes) reaches the else branch and raises this ValueError. This typically means an unknown enum value, a stale enum member removed from the dispatch, or a custom mode passed as a string.","triggerScenarios":"Passing an unrecognized pydantic_program_mode, e.g. a new/removed enum member or a raw string like 'custom'; version skew where the caller's enum has members this llama-index-core version does not handle.","commonSituations":"Mixing llama-index package versions after a partial upgrade; passing a mode constant imported from a different integration; typos in string literals used as modes.","solutions":["Use a supported PydanticProgramMode member: default (omit) or LM_FORMAT_ENFORCER.","Align llama-index-* package versions so the enum and dispatch agree (pip install -U llama-index-core or the meta-package).","If you need a custom program, construct LLMTextCompletionProgram directly instead of via this helper."],"exampleFix":"# before\nprogram = get_program_for_pydantic_model(\n    output_cls, pydantic_program_mode='function_call'  # unsupported\n)\n# after\nfrom llama_index.core.program import PydanticProgramMode\nprogram = get_program_for_pydantic_model(\n    output_cls, pydantic_program_mode=PydanticProgramMode.LM_FORMAT_ENFORCER\n)\n# or omit pydantic_program_mode for the default","handlingStrategy":"validation","validationCode":"from llama_index.core.program import PydanticProgramMode\nSUPPORTED = {PydanticProgramMode.DEFAULT, PydanticProgramMode.LM_FORMAT_ENFORCER}\nif pydantic_program_mode not in SUPPORTED:\n    raise ValueError(f\"unsupported mode: {pydantic_program_mode}\")","typeGuard":"from llama_index.core.program import PydanticProgramMode\n\ndef is_supported_mode(mode) -> bool:\n    return mode in (PydanticProgramMode.DEFAULT,\n                    PydanticProgramMode.LM_FORMAT_ENFORCER)","tryCatchPattern":null,"preventionTips":["Never pass raw strings as pydantic_program_mode; use enum members.","Keep llama-index-* packages version-aligned via the llama-index meta-package."],"tags":["validation","enum","program-mode","version-skew"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}