{"record":{"id":"f303784ed0866aca","repo":"rohitg00/ai-engineering-from-scratch","slug":"path-expected-schema-type-got-type-value","errorCode":null,"errorMessage":"{path}: expected {schema['type']}, got {type(value).__name__}","messagePattern":"(.+?): expected (.+?), got (.+?)","errorType":"validation","errorClass":"SchemaError","httpStatus":null,"severity":"error","filePath":"phases/14-agent-engineering/34-repo-memory-and-state/code/main.py","lineNumber":78,"sourceCode":"def _check_type(value: Any, types: str | list[str]) -> bool:\n    type_list = [types] if isinstance(types, str) else types\n    for t in type_list:\n        if t == \"object\" and isinstance(value, dict):\n            return True\n        if t == \"array\" and isinstance(value, list):\n            return True\n        if t == \"string\" and isinstance(value, str):\n            return True\n        if t == \"integer\" and isinstance(value, int) and not isinstance(value, bool):\n            return True\n        if t == \"null\" and value is None:\n            return True\n    return False\n\n\ndef validate(value: Any, schema: dict[str, Any], path: str = \"$\") -> None:\n    if \"type\" in schema and not _check_type(value, schema[\"type\"]):\n        raise SchemaError(f\"{path}: expected {schema['type']}, got {type(value).__name__}\")\n    if \"enum\" in schema and value not in schema[\"enum\"]:\n        raise SchemaError(f\"{path}: {value!r} not in {schema['enum']}\")\n    if \"pattern\" in schema and isinstance(value, str) and not re.match(schema[\"pattern\"], value):\n        raise SchemaError(f\"{path}: {value!r} does not match /{schema['pattern']}/\")\n    if isinstance(value, dict):\n        for key in schema.get(\"required\", []):\n            if key not in value:\n                raise SchemaError(f\"{path}: missing required field {key!r}\")\n        properties = schema.get(\"properties\", {})\n        unexpected = sorted(set(value.keys()) - set(properties.keys()))\n        if unexpected:\n            raise SchemaError(f\"{path}: unexpected fields {unexpected}\")\n        for key, sub in properties.items():\n            if key in value:\n                validate(value[key], sub, f\"{path}.{key}\")\n    if isinstance(value, list) and \"items\" in schema:\n        for idx, item in enumerate(value):\n            validate(item, schema[\"items\"], f\"{path}[{idx}]\")","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/14-agent-engineering/34-repo-memory-and-state/code/main.py#L60-L96","documentation":"Error \"{path}: expected {schema['type']}, got {type(value).__name__}\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/14-agent-engineering/34-repo-memory-and-state/code/main.py:78 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"}