{"record":{"id":"79bebfd1d3d571fa","repo":"langchain-ai/deepagents","slug":"could-not-read-rubric-file-path-r-exc","errorCode":null,"errorMessage":"Could not read rubric file {path!r}: {exc}.","messagePattern":"Could not read rubric file (.+?): (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/main.py","lineNumber":1533,"sourceCode":"    \"\"\"\n    if rubric is None:\n        return None\n\n    # An `@`-prefixed value is always read as a file path. The path may be\n    # absolute, relative to the `dcode` process working directory, or `~`-based.\n    # There is no way to pass a literal rubric that begins with `@` (put such\n    # text in a file).\n    if rubric.startswith(\"@\"):\n        path = rubric[1:]\n        try:\n            text = Path(path).expanduser().read_text(encoding=\"utf-8\")\n        except (OSError, UnicodeError) as exc:\n            # `UnicodeError` (e.g. `UnicodeDecodeError`) subclasses `ValueError`,\n            # not `OSError`. Catch it here so a binary/non-UTF-8 file yields the\n            # framed \"Could not read rubric file\" message instead of a raw codec\n            # error.\n            msg = f\"Could not read rubric file {path!r}: {exc}.\"\n            raise ValueError(msg) from exc\n        if not text.strip():\n            msg = f\"Rubric file {path!r} is empty.\"\n            raise ValueError(msg)\n        resolved = text.strip()\n        validate_rubric(resolved)\n        return resolved\n\n    if not rubric.strip():\n        msg = \"--rubric must not be empty.\"\n        raise ValueError(msg)\n    resolved = rubric.strip()\n    validate_rubric(resolved)\n    return resolved\n\n\n# The standalone `validate_rubric` above is sufficient here, unlike `/rubric next`,\n# which additionally runs the combined notice check via `_next_rubric_size_error`.\n# That check exists because an in-session one-shot rubric is embedded in the notice","sourceCodeStart":1515,"sourceCodeEnd":1551,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/main.py#L1515-L1551","documentation":"`_resolve_rubric_text` raises `ValueError` when the file passed via `--rubric-file` cannot be read — either an OS-level error (missing file, permissions) or a decode error (binary or non-UTF-8 content). The code deliberately catches `UnicodeError` alongside `OSError` so users get one framed message instead of a raw codec traceback.","triggerScenarios":"`cli_main --rubric-file <path>` where the path does not exist, is a directory, lacks read permission, or contains non-UTF-8 bytes (e.g. a UTF-16 or Latin-1 encoded rubric, or a binary file).","commonSituations":"Typo in the rubric file path; file created on Windows with UTF-16 BOM encoding; rubric exported as a Word/PDF binary; file moved or deleted between shell completion and invocation.","solutions":["Verify the path exists and is readable (`ls -l <path>`), correcting typos","Re-save the rubric file as UTF-8 (e.g. `iconv -f UTF-16 -t UTF-8 rubric.txt > rubric-utf8.txt`)","If the file is genuinely binary, recreate it as plain text"],"exampleFix":"// before\niconv -f UTF-16 -t UTF-8 rubric.txt  # silently mis-decoded or binary content\n// after\nfile -i rubric.txt  # confirm charset\niconv -f UTF-16 -t UTF-8 rubric.txt > rubric-utf8.txt\ndeepagents-code --rubric-file rubric-utf8.txt","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef readable_utf8_file(path: str) -> bool:\n    p = Path(path)\n    if not p.is_file():\n        return False\n    try:\n        p.read_text(encoding=\"utf-8\")\n        return True\n    except (OSError, UnicodeError):\n        return False\n\n# before: --rubric-file <path>\nassert readable_utf8_file(path), f\"{path} missing or not UTF-8\"","typeGuard":null,"tryCatchPattern":"try:\n    rubric = _resolve_rubric_text(args)\nexcept ValueError as exc:\n    raise SystemExit(f\"bad rubric input: {exc}\")","preventionTips":["Save rubric files as UTF-8 (check editor encoding settings)","Verify the path with `file -i` when moving files between OSes","Never point --rubric-file at binary formats (PDF, docx)"],"tags":["filesystem","encoding","cli"],"backgroundTag":"file-read-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}