{"record":{"id":"59b8df80e39e0349","repo":"rohitg00/ai-engineering-from-scratch","slug":"path-value-r-does-not-match-schema-pattern","errorCode":null,"errorMessage":"{path}: {value!r} does not match /{schema['pattern']}/","messagePattern":"(.+?): (.+?) does not match /(.+?)/","errorType":"validation","errorClass":"SchemaError","httpStatus":null,"severity":"error","filePath":"phases/14-agent-engineering/34-repo-memory-and-state/code/main.py","lineNumber":82,"sourceCode":"            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}]\")\n\n\ndef atomic_write(path: Path, content: str) -> None:\n    path.parent.mkdir(parents=True, exist_ok=True)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/14-agent-engineering/34-repo-memory-and-state/code/main.py#L64-L100","documentation":"Pattern branch of the mini JSON-Schema validator: the string at the given path failed re.match against the schema's regex pattern (applied from the start of the string). The value is a string but its spelling does not conform to the required format, e.g. an id or key naming convention.","triggerScenarios":"Thrown at phases/14-agent-engineering/34-repo-memory-and-state/code/main.py:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rewrite the value to match the pattern shown in the error","Anchor expectations with test strings known to match","Update the pattern if the format rule changed intentionally","Remember re.match anchors at the string start; trailing garbage also fails"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}