langchain-ai/langchain · error · NotImplementedError
_HashedDocument is an internal abstraction that was deprecat
Error message
_HashedDocument is an internal abstraction that was deprecated in langchain-core 0.3.63. This abstraction is marked as private and should not have been used directly. If you are seeing this error, please update your code appropriately.
What it means
`_HashedDocument` was a private helper in the indexing API that some users imported anyway. In langchain-core 0.3.63 its logic moved into `_get_document_with_hash` and the class was turned into a stub whose `__init__` always raises `NotImplementedError`. The class is kept importable purely so old imports do not break with an ImportError, but instantiating it is now a hard failure.
Source
Thrown at libs/core/langchain_core/indexing/api.py:244
# Assign a unique identifier based on the hash.
id=hash_,
page_content=document.page_content,
metadata=document.metadata,
)
# This internal abstraction was imported by the langchain package internally, so
# we keep it here for backwards compatibility.
class _HashedDocument:
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Raise an error if this class is instantiated."""
msg = (
"_HashedDocument is an internal abstraction that was deprecated in "
" langchain-core 0.3.63. This abstraction is marked as private and "
" should not have been used directly. If you are seeing this error, please "
" update your code appropriately."
)
raise NotImplementedError(msg)
def _delete(
vector_store: VectorStore | DocumentIndex,
ids: list[str],
) -> None:
"""Delete documents from a vector store or document index by their IDs.
Args:
vector_store: The vector store or document index to delete from.
ids: List of document IDs to delete.
Raises:
IndexingException: If the delete operation fails.
TypeError: If the `vector_store` is neither a `VectorStore` nor a
`DocumentIndex`.
"""
if isinstance(vector_store, VectorStore):View on GitHub (pinned to e32fa9a52e)
Solutions
- Replace direct construction with a call to the public indexing API — `index()` hashes documents internally.
- If you need a hashed document yourself, compute it via a callable passed as `key_encoder`, or hash content+metadata with hashlib in your own code.
- Pin langchain-core < 0.3.63 only as a last-resort temporary stopgap while migrating.
Example fix
# before
hashed = _HashedDocument(page_content=doc.page_content)
# after
# let the indexer hash; or roll your own
import hashlib, uuid
uid = uuid.uuid5(uuid.NAMESPACE_URL, doc.page_content)
hashed = doc.model_copy(update={"id": str(uid)}) Defensive patterns
Strategy: try-catch
Validate before calling
import langchain_core.indexing.api as api
if hasattr(api, "_get_document_with_hash"):
... # new API available; do not touch _HashedDocument Try / catch
try:
hashed = _HashedDocument(...) # legacy path
except NotImplementedError:
hashed = None # fall back to letting index() hash internally Prevention
- Never import underscore-prefixed names from langchain_core; they can be stubbed at any release.
- Search your code and pinned third-party libs for '_HashedDocument' before upgrading langchain-core.
When it happens
Trigger: `from langchain_core.indexing.api import _HashedDocument` followed by `_HashedDocument(...)`; older code or third-party packages (including some langchain-classic internals) that constructed it directly to pre-hash documents.
Common situations: Upgrading langchain-core past 0.3.63 with code that pre-hashed documents before calling index(); vendored tutorials or notebooks referencing the private class; CopyPasta from the indexing module's internals.
Related errors
- A pending deprecation cannot have a scheduled removal
- Cannot specify both alternative and alternative_import
- alternative_import must be a fully qualified module path. Go
- Field {obj} must have a name to be deprecated.
- {f.__name__}() got multiple values for argument {new!r}
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/2e062ebcfad0ed0a.
Report an issue: GitHub.