{"record":{"id":"7b66ef5d55abf276","repo":"rohitg00/ai-engineering-from-scratch","slug":"invalid-value-for-location-not-in-enum","errorCode":null,"errorMessage":"invalid value for {location}: not in enum","messagePattern":"invalid value for (.+?): not in enum","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/10-tool-use-and-agentic-loops/code/main.py","lineNumber":126,"sourceCode":"def _validate_schema_value(value: Any, schema: Any, location: str) -> None:\n    if not isinstance(schema, dict):\n        raise ValueError(f\"schema for {location} must be an object\")\n\n    declared_type = schema.get(\"type\")\n    if declared_type is not None:\n        declared_types = declared_type if isinstance(declared_type, list) else [declared_type]\n        if not declared_types or not all(isinstance(item, str) for item in declared_types):\n            raise ValueError(f\"schema type for {location} must be a string or non-empty string list\")\n        if not any(_matches_json_type(value, item) for item in declared_types):\n            expected = \" or \".join(declared_types)\n            raise ValueError(f\"invalid type for {location}: expected {expected}\")\n\n    if \"enum\" in schema:\n        choices = schema[\"enum\"]\n        if not isinstance(choices, list) or not choices:\n            raise ValueError(f\"schema enum for {location} must be a non-empty list\")\n        if value not in choices:\n            raise ValueError(f\"invalid value for {location}: not in enum\")\n\n    if isinstance(value, (int, float)) and not isinstance(value, bool):\n        for keyword, comparison, message in (\n            (\"minimum\", lambda current, bound: current >= bound, \"below minimum\"),\n            (\"maximum\", lambda current, bound: current <= bound, \"above maximum\"),\n            (\"exclusiveMinimum\", lambda current, bound: current > bound, \"at or below exclusive minimum\"),\n            (\"exclusiveMaximum\", lambda current, bound: current < bound, \"at or above exclusive maximum\"),\n        ):\n            if keyword not in schema:\n                continue\n            bound = schema[keyword]\n            if not isinstance(bound, (int, float)) or isinstance(bound, bool):\n                raise ValueError(f\"schema {keyword} for {location} must be numeric\")\n            if not comparison(value, bound):\n                raise ValueError(f\"invalid value for {location}: {message} {bound}\")\n\n    if isinstance(value, str):\n        minimum = _integer_bound(schema, \"minLength\")","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/10-tool-use-and-agentic-loops/code/main.py#L108-L144","documentation":"Error \"invalid value for {location}: not in enum\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/10-tool-use-and-agentic-loops/code/main.py:126 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":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}