{"record":{"id":"ca11926a88f54348","repo":"MemPalace/mempalace","slug":"source-file-contains-null-bytes","errorCode":null,"errorMessage":"source_file contains null bytes","messagePattern":"source_file contains null bytes","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/mcp_server.py","lineNumber":1817,"sourceCode":"\n    Unlike wing/room, a source_file is a path: ``/``, ``\\\\`` and ``.`` are\n    legal, so it is NOT run through ``sanitize_name`` (which rejects path\n    characters as traversal attempts). The value is matched verbatim as a\n    ChromaDB metadata-equality / parameterized-SQL value — never used as a\n    filesystem path — so there is no traversal risk to guard against. A null\n    byte or a pathological length can still upset the backend (chromadb\n    add/upsert chokes on null bytes / lone surrogates, #1235), so guard those\n    for parity with ``sanitize_name``. Blank / whitespace-only is \"no filter\".\n    \"\"\"\n    if value is None:\n        return None\n    if not isinstance(value, str):\n        raise ValueError(\"source_file must be a string\")\n    value = value.strip()\n    if not value:\n        return None\n    if \"\\x00\" in value:\n        raise ValueError(\"source_file contains null bytes\")\n    if value != strip_lone_surrogates(value):\n        raise ValueError(\"source_file contains invalid surrogate characters\")\n    if len(value) > _MAX_SOURCE_FILE_LENGTH:\n        raise ValueError(\n            f\"source_file exceeds maximum length of {_MAX_SOURCE_FILE_LENGTH} characters\"\n        )\n    return value\n\n\n# The #1128 date-filter helpers moved to ``mempalace.date_window`` so the\n# search-side window (#463) can share them without importing this module\n# (whose import installs MCP stdio protection). Aliased under their\n# historical private names — every call site and test keeps working.\n_parse_date_filter = parse_date_bound\n_filed_at_in_window = filed_at_in_window\n\n\n# ==================== READ TOOLS ====================","sourceCodeStart":1799,"sourceCodeEnd":1835,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/mcp_server.py#L1799-L1835","documentation":"Error \"source_file contains null bytes\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/mcp_server.py:1817 when the library encounters an invalid state.","commonSituations":"Client payload contained a NUL character in the path.","solutions":["Remove null bytes from the source_file value"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}