Repository navigation
Description
Issue Summary
Production tenant logs reveal several bugs causing repeated errors during normal operations. These need better error handling and validation.
Bugs Identified
1. Tags handling: 'dict' object has no attribute 'strip'
Frequency: ~40 occurrences in 12 hours
Affected files: Multiple (L2_regulation/GOV/.md, L3_design/emotion/.md, etc.)
The code expects tags to be strings but receives dict objects. Need to handle both string and dict tag formats gracefully.
Example errors:
Error writing resource L2_regulation/GOV/rgs.md: 'dict' object has no attribute 'strip'Error writing resource L3_design/emotion/biorhythm_and_color_profile.md: 'dict' object has no attribute 'strip'
Fix needed: Add type checking and conversion for tags in frontmatter parsing.
2. Double slashes in file paths causing DB conflicts
Frequency: Multiple occurrences
Affected files: L3_design/emotion//biorhythm_and_color_profile.md
Double slashes in paths cause UNIQUE constraint violations in the database.
Example errors:
(sqlite3.IntegrityError) UNIQUE constraint failed: entity.file_path, entity.project_id
[SQL: INSERT INTO entity ... file_path='L3_design/emotion//biorhythm_and_color_profile.md' ...]
Fix needed:
- Normalize paths before database operations (remove double slashes)
- Better error messages explaining the path issue to users
- Potentially auto-fix double slashes during write operations
3. Invalid YAML frontmatter crashes
Example:
tags:[design,thesis] # Missing space after colonError:
ParseError: Invalid YAML in frontmatter: could not find expected ':'
Fix needed:
- Better YAML validation with helpful error messages
- Suggest corrections (e.g., "Did you mean 'tags: [design,thesis]'?")
- Consider more lenient parsing or auto-correction
4. Edit operation text not found
Frequency: Multiple occurrences
Users attempting find/replace operations that fail because text doesn't match exactly.
Example:
Error editing entity: Text to replace not found: '| 30.10.2025 | **GERICHTSTERMIN...'
Fix needed:
- More helpful error messages showing what was searched for and what was found
- Fuzzy matching suggestions
- Preview mode for edit operations
5. Import failures with missing fields
Error:
Import failed: AttributeError: 'NoneType' object has no attribute 'success'
Failed to import memory.json: KeyError: 'type'
Fix needed:
- Better validation of import data structure
- Clear error messages about required fields
- Graceful degradation (import what's valid, report what failed)
Priority
High - These bugs cause repeated failures in production and degrade user experience.
Affected Users
Currently affecting production tenant e5d1c86a (power user with complex data structure).
Reproduction
These are all visible in Logfire production logs for the last 12 hours.
Proposed Solutions
- Add robust type checking for all frontmatter fields
- Normalize file paths consistently
- Improve YAML parser error messages
- Add validation layers before database operations
- Better error messages with actionable suggestions
- Consider adding
--strictvs--lenientmodes for parsing
Activity
claude commentedon Nov 13, 2025
Claude finished @phernandez's task —— View job •
claude/issue-431-20251113-1619• Create PR ➔Production Bugs Fixed ✓
I've successfully implemented and committed fixes for all 5 production bugs reported in this issue.
Issue Triage
Fixes Implemented
Bug #1: Tags Dict Handling
File:
src/basic_memory/utils.pyAdded handling for dict objects in
parse_tags()function. When frontmatter contains malformed YAML liketags:{key:value}, PyYAML parses it as a dict instead of failing. The fix:.strip()operationstags: [tag1, tag2]Bug #2: Path Normalization
Files:
src/basic_memory/file_utils.py,src/basic_memory/schemas/base.py,src/basic_memory/api/routers/resource_router.pyCreated
normalize_path_separators()function to prevent double slashes causing DB UNIQUE constraint violations:folder//file.md→folder/file.md)Entity.file_pathproperty (where paths are constructed)Bug #3: YAML Error Messages
File:
src/basic_memory/file_utils.pyEnhanced
parse_frontmatter()to provide actionable suggestions for common YAML mistakes:key:valuevskey: value)Bug #4: Edit Operation Error Context
File:
src/basic_memory/services/entity_service.pyImproved "Text to replace not found" error in
apply_edit_operation():read_note()to verify the exact textBug #5: Import Validation
File:
src/basic_memory/importers/memory_json_importer.pyAdded comprehensive validation before accessing data fields:
skipped_entitiescounter for reportingTechnical Details
All fixes include:
The changes are backward compatible and handle both valid and invalid data gracefully.
Files Changed
src/basic_memory/utils.py- Tags dict handlingsrc/basic_memory/file_utils.py- Path normalization + YAML errorssrc/basic_memory/schemas/base.py- Path normalization in Entitysrc/basic_memory/api/routers/resource_router.py- Path normalization in APIsrc/basic_memory/services/entity_service.py- Edit error contextsrc/basic_memory/importers/memory_json_importer.py- Import validationNext Steps
The fixes are ready for review. These changes should significantly reduce the error rates reported in production logs.
--- | Branch: claude/issue-431-20251113-1619
fix: Improve data validation and error handling for production bugs (#…