run-llama/llama_index · error · ValueError
embedding not set.
Error message
embedding not set.
What it means
BaseNode.get_embedding() raises ValueError when the node's embedding field is None. The API intentionally errors instead of returning None because callers (vector stores, similarity rerankers) require an actual vector; nodes created by parsers start with embedding=None until an embedding model runs on them.
Source
Thrown at llama-index-core/llama_index/core/schema.py:491
def __str__(self) -> str:
source_text_truncated = truncate_text(
self.get_content().strip(), TRUNCATE_LENGTH
)
source_text_wrapped = textwrap.fill(
f"Text: {source_text_truncated}\n", width=WRAP_WIDTH
)
return f"Node ID: {self.node_id}\n{source_text_wrapped}"
def get_embedding(self) -> List[float]:
"""
Get embedding.
Errors if embedding is None.
"""
if self.embedding is None:
raise ValueError("embedding not set.")
return self.embedding
def as_related_node_info(self) -> RelatedNodeInfo:
"""Get node as RelatedNodeInfo."""
return RelatedNodeInfo(
node_id=self.node_id,
node_type=self.get_type(),
metadata=self.metadata,
hash=self.hash,
)
EmbeddingKind = Literal["sparse", "dense"]
class MediaResource(BaseModel):
"""
A container class for media content.View on GitHub (pinned to afd0fef371)
Solutions
- Embed first: node.embedding = Settings.embedding_model.get_text_embedding(node.get_content())
- Run nodes through an IngestionPipeline with an embedding transform before touching embeddings
- If a node may legitimately lack an embedding, check node.embedding is None yourself instead of calling get_embedding()
Example fix
# before
vec = node.get_embedding() # ValueError if never embedded
# after
if node.embedding is None:
node.embedding = Settings.embedding_model.get_text_embedding(node.get_content())
vec = node.get_embedding() Defensive patterns
Strategy: validation
Validate before calling
if node.embedding is None:
node.embedding = Settings.embedding_model.get_text_embedding(node.get_content()) Type guard
def is_embedded(node) -> bool:
return node.embedding is not None Prevention
- Embed nodes during ingestion via IngestionPipeline, not lazily at read time
- Check .embedding is None before get_embedding()
- Keep a single node source so you never read un-embedded copies
When it happens
Trigger: Calling node.get_embedding() on a node that was never embedded — i.e., created via TextNode()/SentenceSplitter but not passed through Settings.embedding_model.get_text_embedding or an ingestion pipeline embedding step.
Common situations: Custom retrieval or reranking code that inspects node embeddings after loading un-embedded nodes from a docstore; building a vector index but reading nodes from the wrong (non-embedded) copy.
Related errors
- Source object must be a single RelatedNodeInfo object
- Previous object must be a single RelatedNodeInfo object
- Next object must be a single RelatedNodeInfo object
- Parent object must be a single RelatedNodeInfo object
- Child objects must be a list of RelatedNodeInfo objects.
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/7fad7faf288a1493.
Report an issue: GitHub.