-
Notifications
You must be signed in to change notification settings - Fork 150
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
When viewing entities that have relations to entities with null permalinks, the API returns a 500 error:
500: Internal proxy error: 1 validation error for EntityResponseV2
relations.0.from_entity.permalink
Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
Root Cause
In src/basic_memory/schemas/response.py, the RelationResponse schema has:
from_id: Permalink = Field(
validation_alias=AliasChoices(
AliasPath("from_entity", "permalink"), # Tries this FIRST
"from_id",
)
)When from_entity.permalink is None (which is valid for imported notes without permalinks enabled), Pydantic fails validation because from_id is typed as Permalink (non-nullable Annotated[str, MinLen(1)]).
Reproduction
- Import notes from a local environment where permalinks were not enabled
- Create a relation between an entity with a permalink and one without
- Try to view the entity with the relation via
/v2/projects/{id}/knowledge/entities/{id} - 500 error occurs
Evidence
From production Logfire trace for user with imported notes:
- 212 out of 345 entities (61%) have null permalinks
- Viewing entity 346 fails because relation id 205 references entity 42 which has
permalink: null
Proposed Fix
Either:
- Make
from_idoptional:from_id: Optional[Permalink] = Field(...) - Or add proper fallback handling when
from_entity.permalinkis None (use entity title or file_path as fallback)
Option 2 is preferred since it maintains backwards compatibility and provides a meaningful value.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working