{"record":{"id":"1ec102fd0f0601d8","repo":"HKUDS/nanobot","slug":"unknown-old-text","errorCode":null,"errorMessage":"Unknown old_text","messagePattern":"Unknown old_text","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"nanobot/agent/tools/filesystem.py","lineNumber":928,"sourceCode":"            \"Shows closest-match diagnostics on failure.\"\n        )\n\n    @staticmethod\n    def _strip_trailing_ws(text: str) -> str:\n        \"\"\"Strip trailing whitespace from each line.\"\"\"\n        return \"\\n\".join(line.rstrip() for line in text.split(\"\\n\"))\n\n    async def execute(\n        self, path: str | None = None, old_text: str | None = None,\n        new_text: str | None = None,\n        replace_all: bool = False, occurrence: int | None = None,\n        line_hint: int | None = None, expected_replacements: int | None = None, **kwargs: Any,\n    ) -> str:\n        try:\n            if not path:\n                raise ValueError(\"Unknown path\")\n            if old_text is None:\n                raise ValueError(\"Unknown old_text\")\n            if new_text is None:\n                raise ValueError(\"Unknown new_text\")\n            if occurrence is not None and occurrence < 1:\n                return ToolResult.error(\"Error: occurrence must be >= 1.\")\n            if line_hint is not None and line_hint < 1:\n                return ToolResult.error(\"Error: line_hint must be >= 1.\")\n            if expected_replacements is not None and expected_replacements < 1:\n                return ToolResult.error(\"Error: expected_replacements must be >= 1.\")\n\n            fp = self._resolve_write(path)\n            file_exists = fp.exists()\n            if file_exists and old_text == new_text:\n                return ToolResult.error(\"Error: new_text must be different from old_text.\")\n\n            # Create-file semantics: old_text='' + file doesn't exist → create\n            if not file_exists:\n                if old_text == \"\":\n                    fp.parent.mkdir(parents=True, exist_ok=True)","sourceCodeStart":910,"sourceCodeEnd":946,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/agent/tools/filesystem.py#L910-L946","documentation":"Error \"Unknown old_text\" thrown in HKUDS/nanobot.","triggerScenarios":"Thrown at nanobot/agent/tools/filesystem.py:928 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":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}