Skip to content

Multiple data validation and error handling bugs in production #431

@phernandez

Description

@phernandez

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 colon

Error:

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

  1. Add robust type checking for all frontmatter fields
  2. Normalize file paths consistently
  3. Improve YAML parser error messages
  4. Add validation layers before database operations
  5. Better error messages with actionable suggestions
  6. Consider adding --strict vs --lenient modes for parsing

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions