You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Validation error on edit_note while it successfully edits the note #170
I get the following error when asking Claude Desktop to edit a note:
Edit Failed
Error editing note 'note.md': 1 validation error for EntityResponse
permalink
Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
Interestingly enough, the actual action (appending to the note) goes through successfully.
thanks for the bug @Narsail. You have to be a member of our org to have Claude summoning powers :). It uses our api key. If you don't mind, can you share your log from ~/.basic-memory/basic-memory-mcp.log? It may have more info about the error.
Found and fixed the issue! The problem was in the edit_entity workflow:
edit_note calls PATCH /knowledge/entities/{identifier} → edit_entity API endpoint
edit_entity API calls entity_service.edit_entity() method
This method re-parses the file after editing: await self.entity_parser.parse_file(file_path)
The parsed EntityMarkdown object gets passed to entity_model_from_markdown()
The bug: entity_model_from_markdown() unconditionally set model.permalink = markdown.frontmatter.permalink
When markdown files don't have a permalink field in their frontmatter (which is common), the frontmatter.permalink is None, so it overwrote the existing permalink in the database entity with None.
The API then tried to validate this with EntityResponse.model_validate(entity) but EntityResponse requires permalink: Permalink (which is Annotated[str, MinLen(1)]), causing the validation error.
The Fix
File: src/basic_memory/markdown/utils.py:41-43
Changed from:
model.permalink=markdown.frontmatter.permalink
To:
# Only update permalink if it exists in frontmatter, otherwise preserve existingifmarkdown.frontmatter.permalinkisnotNone:
model.permalink=markdown.frontmatter.permalink
This preserves the existing permalink when the markdown frontmatter doesn't contain one, preventing the validation error.
Testing
Added a comprehensive regression test in tests/mcp/test_tool_edit_note.py that specifically tests the scenario where a note is edited multiple times without a permalink in frontmatter. This ensures the bug doesn't recur.
The edit operation now succeeds without validation errors while preserving all existing functionality.
@phernandez I checked the log. Here are the events at the time it happened. I had to redact the actual note name:
2025-06-24 12:13:59.222 | INFO | basic_memory.mcp.tools.search:search_notes:272 - Searching for permalink=None permalink_match=None text='Note' title=None types=None entity_types=None after_date=None
2025-06-24 12:13:59.260 | INFO | basic_memory.mcp.tools.search:search_notes:285 - Search returned no results for query: Note
2025-06-24 12:14:01.740 | INFO | basic_memory.mcp.tools.search:search_notes:272 - Searching for permalink=None permalink_match=None text='Note' title=None types=None entity_types=None after_date=None
2025-06-24 12:14:04.928 | INFO | basic_memory.mcp.tools.read_note:read_note:68 - Attempting to read note from URL: /Note.md
2025-06-24 12:14:04.947 | INFO | basic_memory.mcp.tools.read_note:read_note:76 - Returning read_note result from resource: Note.md
2025-06-24 12:15:03.441 | INFO | basic_memory.mcp.tools.edit_note:edit_note:206 - MCP tool call
2025-06-24 12:15:03.451 | INFO | basic_memory.api.routers.knowledge_router:edit_entity:121 - API request: endpoint='edit_entity', identifier='Note.md', operation='append'
2025-06-24 12:15:03.462 | INFO | basic_memory.services.file_service:write_file:132 - Writing file: path=Note.md, content_length=15331, is_markdown=True
2025-06-24 12:15:03.517 | ERROR | basic_memory.api.routers.knowledge_router:edit_entity:154 - Error editing entity: 1 validation error for EntityResponse
permalink
Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.11/v/string_type
2025-06-24 12:15:03.517 | INFO | basic_memory.mcp.tools.utils:call_patch:321 - Client error: PATCH Note.md: 1 validation error for EntityResponse
permalink
Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.11/v/string_type
2025-06-24 12:15:03.518 | ERROR | basic_memory.mcp.tools.edit_note:edit_note:300 - Error editing note: 1 validation error for EntityResponse
permalink
Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.11/v/string_type
What are you using to run Claude against this repo like it does? Is that something 'off the shelf' or self built?
Activity
Narsail commentedon Jun 24, 2025
@claude Can you do your magic? (I think he doesn't like me)
phernandez commentedon Jun 24, 2025
thanks for the bug @Narsail. You have to be a member of our org to have Claude summoning powers :). It uses our api key. If you don't mind, can you share your log from ~/.basic-memory/basic-memory-mcp.log? It may have more info about the error.
phernandez commentedon Jun 24, 2025
@claude can you look at the error message the user received? I think this issue may be related to #155
claude commentedon Jun 24, 2025
Claude finished @phernandez's task —— View job •
claude/issue-170-20250624_132506• Create PR ➔Fixed edit_note validation error ✅
Todo List:
Root Cause Analysis
Found and fixed the issue! The problem was in the
edit_entityworkflow:edit_notecalls PATCH/knowledge/entities/{identifier}→edit_entityAPI endpointedit_entityAPI callsentity_service.edit_entity()methodawait self.entity_parser.parse_file(file_path)EntityMarkdownobject gets passed toentity_model_from_markdown()entity_model_from_markdown()unconditionally setmodel.permalink = markdown.frontmatter.permalinkWhen markdown files don't have a
permalinkfield in their frontmatter (which is common), the frontmatter.permalink isNone, so it overwrote the existing permalink in the database entity withNone.The API then tried to validate this with
EntityResponse.model_validate(entity)butEntityResponserequirespermalink: Permalink(which isAnnotated[str, MinLen(1)]), causing the validation error.The Fix
File:
src/basic_memory/markdown/utils.py:41-43Changed from:
To:
This preserves the existing permalink when the markdown frontmatter doesn't contain one, preventing the validation error.
Testing
Added a comprehensive regression test in
tests/mcp/test_tool_edit_note.pythat specifically tests the scenario where a note is edited multiple times without a permalink in frontmatter. This ensures the bug doesn't recur.The edit operation now succeeds without validation errors while preserving all existing functionality.
--- | Branch: claude/issue-170-20250624_132506
fix: preserve permalink when editing notes without frontmatter permalink
Narsail commentedon Jun 24, 2025
@phernandez I checked the log. Here are the events at the time it happened. I had to redact the actual note name:
What are you using to run Claude against this repo like it does? Is that something 'off the shelf' or self built?
phernandez commentedon Jun 24, 2025
@Narsail We use the claude code actions https://docs.anthropic.com/en/docs/claude-code/github-actions
It's been working great
phernandez commentedon Jun 26, 2025
fixed in #184
bm-claudeai commentedon Jun 26, 2025
Test comment
fix: add test coverage for optional permalink in EntityResponse schema
jcelliott commentedon Jul 25, 2025
I'm seeing the same behavior on the latest version of basic-memory. It seems that PR didn't actually fix it?
refactor(mcp): remove read_note, edit_note, workspaces and chatgpt to…