Home / Function/ test_catches_forbidden_keys() — langchain Function Reference

test_catches_forbidden_keys() — langchain Function Reference

Architecture documentation for the test_catches_forbidden_keys() function in test_filesystem.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b9ef9ddd_4d2e_f528_fc9c_9d4fc12faf7c["test_catches_forbidden_keys()"]
  dc21888b_994e_4dfd_2387_4da22b01f8de["test_filesystem.py"]
  b9ef9ddd_4d2e_f528_fc9c_9d4fc12faf7c -->|defined in| dc21888b_994e_4dfd_2387_4da22b01f8de
  style b9ef9ddd_4d2e_f528_fc9c_9d4fc12faf7c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/storage/test_filesystem.py lines 135–158

def test_catches_forbidden_keys(file_store: LocalFileStore) -> None:
    """Test that forbidden keys raise exceptions.

    Make sure we raise exception on keys that are not allowed; e.g., absolute path.
    """
    with pytest.raises(InvalidKeyException):
        file_store.mset([("/etc", b"value1")])
    with pytest.raises(InvalidKeyException):
        list(file_store.yield_keys(prefix="/etc/passwd"))
    with pytest.raises(InvalidKeyException):
        file_store.mget(["/etc/passwd"])

    # check relative paths
    with pytest.raises(InvalidKeyException):
        list(file_store.yield_keys(prefix=".."))

    with pytest.raises(InvalidKeyException):
        file_store.mget(["../etc/passwd"])

    with pytest.raises(InvalidKeyException):
        file_store.mset([("../etc", b"value1")])

    with pytest.raises(InvalidKeyException):
        list(file_store.yield_keys(prefix="../etc/passwd"))

Domain

Subdomains

Frequently Asked Questions

What does test_catches_forbidden_keys() do?
test_catches_forbidden_keys() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/storage/test_filesystem.py.
Where is test_catches_forbidden_keys() defined?
test_catches_forbidden_keys() is defined in libs/langchain/tests/unit_tests/storage/test_filesystem.py at line 135.

Analyze Your Own Codebase

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

Try Supermodel Free