Home / Function/ _validate_path() — anthropic-sdk-python Function Reference

_validate_path() — anthropic-sdk-python Function Reference

Architecture documentation for the _validate_path() function in basic.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  42a84966_de9f_298e_a98d_c527baf8aa0e["_validate_path()"]
  c2730250_7059_6f44_aa62_71ce88c5a804["LocalFilesystemMemoryTool"]
  42a84966_de9f_298e_a98d_c527baf8aa0e -->|defined in| c2730250_7059_6f44_aa62_71ce88c5a804
  460f1285_af24_2579_35b7_ffa668dec7e8["view()"]
  460f1285_af24_2579_35b7_ffa668dec7e8 -->|calls| 42a84966_de9f_298e_a98d_c527baf8aa0e
  13e9cc96_46e7_62d7_b163_144f30ec7903["create()"]
  13e9cc96_46e7_62d7_b163_144f30ec7903 -->|calls| 42a84966_de9f_298e_a98d_c527baf8aa0e
  d99fe51f_04cf_c035_7ebe_a5ab0468d24f["str_replace()"]
  d99fe51f_04cf_c035_7ebe_a5ab0468d24f -->|calls| 42a84966_de9f_298e_a98d_c527baf8aa0e
  78edd0c5_3b20_e27e_ccfe_28854eba9ca6["insert()"]
  78edd0c5_3b20_e27e_ccfe_28854eba9ca6 -->|calls| 42a84966_de9f_298e_a98d_c527baf8aa0e
  9953ad4e_3ee1_dc26_47f7_ab01c3e451fc["delete()"]
  9953ad4e_3ee1_dc26_47f7_ab01c3e451fc -->|calls| 42a84966_de9f_298e_a98d_c527baf8aa0e
  844c0a45_b4be_4cdf_b586_46d2b9a05aeb["rename()"]
  844c0a45_b4be_4cdf_b586_46d2b9a05aeb -->|calls| 42a84966_de9f_298e_a98d_c527baf8aa0e
  style 42a84966_de9f_298e_a98d_c527baf8aa0e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/memory/basic.py lines 62–75

    def _validate_path(self, path: str) -> Path:
        """Validate and resolve memory paths"""
        if not path.startswith("/memories"):
            raise ValueError(f"Path must start with /memories, got: {path}")

        relative_path = path[len("/memories") :].lstrip("/")
        full_path = self.memory_root / relative_path if relative_path else self.memory_root

        try:
            full_path.resolve().relative_to(self.memory_root.resolve())
        except ValueError as e:
            raise ValueError(f"Path {path} would escape /memories directory") from e

        return full_path

Subdomains

Frequently Asked Questions

What does _validate_path() do?
_validate_path() is a function in the anthropic-sdk-python codebase, defined in examples/memory/basic.py.
Where is _validate_path() defined?
_validate_path() is defined in examples/memory/basic.py at line 62.
What calls _validate_path()?
_validate_path() is called by 6 function(s): create, delete, insert, rename, str_replace, view.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free