Home / Function/ _warn_about_sha1() — langchain Function Reference

_warn_about_sha1() — langchain Function Reference

Architecture documentation for the _warn_about_sha1() function in api.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  2c0b432c_e428_0793_33b7_2246ae04f57c["_warn_about_sha1()"]
  0a83ef61_4c07_e8b4_648c_4199ec598979["api.py"]
  2c0b432c_e428_0793_33b7_2246ae04f57c -->|defined in| 0a83ef61_4c07_e8b4_648c_4199ec598979
  15e1884a_a842_1f4a_5894_1426029cd476["_hash_string()"]
  15e1884a_a842_1f4a_5894_1426029cd476 -->|calls| 2c0b432c_e428_0793_33b7_2246ae04f57c
  38094325_d9b6_a147_c56c_209933148cce["index()"]
  38094325_d9b6_a147_c56c_209933148cce -->|calls| 2c0b432c_e428_0793_33b7_2246ae04f57c
  4540ac2f_95e9_c32c_6eec_88589007c350["aindex()"]
  4540ac2f_95e9_c32c_6eec_88589007c350 -->|calls| 2c0b432c_e428_0793_33b7_2246ae04f57c
  style 2c0b432c_e428_0793_33b7_2246ae04f57c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/indexing/api.py lines 55–70

def _warn_about_sha1() -> None:
    """Emit a one-time warning about SHA-1 collision weaknesses."""
    # Global variable OK in this case
    global _WARNED_ABOUT_SHA1  # noqa: PLW0603
    if not _WARNED_ABOUT_SHA1:
        warnings.warn(
            "Using SHA-1 for document hashing. SHA-1 is *not* "
            "collision-resistant; a motivated attacker can construct distinct inputs "
            "that map to the same fingerprint. If this matters in your "
            "threat model, switch to a stronger algorithm such "
            "as 'blake2b', 'sha256', or 'sha512' by specifying "
            " `key_encoder` parameter in the `index` or `aindex` function. ",
            category=UserWarning,
            stacklevel=2,
        )
        _WARNED_ABOUT_SHA1 = True

Subdomains

Frequently Asked Questions

What does _warn_about_sha1() do?
_warn_about_sha1() is a function in the langchain codebase, defined in libs/core/langchain_core/indexing/api.py.
Where is _warn_about_sha1() defined?
_warn_about_sha1() is defined in libs/core/langchain_core/indexing/api.py at line 55.
What calls _warn_about_sha1()?
_warn_about_sha1() is called by 3 function(s): _hash_string, aindex, index.

Analyze Your Own Codebase

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

Try Supermodel Free