HKUDS/DeepTutor · error · VaultError

Note {path.name!r} is not valid UTF-8 (byte offset {exc.star

Error message

Note {path.name!r} is not valid UTF-8 (byte offset {exc.start}); editing it would corrupt the undecodable bytes. Fix its encoding first.

What it means

Error "Note {path.name!r} is not valid UTF-8 (byte offset {exc.start}); editing it would corrupt the undecodable bytes. Fix its encoding first." thrown in HKUDS/DeepTutor.

Source

Thrown at deeptutor/capabilities/obsidian/vault.py:82

    Reads only. A read-modify-write must use :func:`_read_text_exact`, which
    refuses to launder those bytes back onto disk.
    """
    return path.read_text(encoding="utf-8", errors="replace")


def _read_text_exact(path: Path) -> str:
    """Decode a note that is about to be written back, without substitution.

    Rewriting a note we could only partially decode would replace the user's
    bytes with U+FFFD, so writes stay strict. Raising ``VaultError`` (rather
    than letting ``UnicodeDecodeError`` escape) is what makes the refusal
    legible: the tool layer turns it into a message naming the note and the
    fix, instead of an opaque failure.
    """
    try:
        return path.read_text(encoding="utf-8")
    except UnicodeDecodeError as exc:
        raise VaultError(
            f"Note {path.name!r} is not valid UTF-8 (byte offset {exc.start}); "
            "editing it would corrupt the undecodable bytes. Fix its encoding first."
        ) from exc


def _safe_join(root: Path, rel: str) -> Path:
    """Resolve ``rel`` under ``root``, refusing anything that escapes the vault."""
    root_resolved = root.resolve()
    candidate = (root_resolved / rel.lstrip("/")).resolve()
    if candidate != root_resolved and root_resolved not in candidate.parents:
        raise VaultError(f"Path {rel!r} escapes the vault.")
    return candidate


def _with_md_suffix(rel: str) -> str:
    return rel if rel.lower().endswith(".md") else f"{rel}.md"

View on GitHub (pinned to 3e82f13042)

When it happens

Trigger: Thrown at deeptutor/capabilities/obsidian/vault.py:82 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/2fe828d11c98440c. Report an issue: GitHub.