Skip to content

fix(migrate): keep OKF batches valid with long titles#1516

Open
jackmercy wants to merge 1 commit into
moorcheh-ai:mainfrom
jackmercy:fix/okf-long-title-import
Open

fix(migrate): keep OKF batches valid with long titles#1516
jackmercy wants to merge 1 commit into
moorcheh-ai:mainfrom
jackmercy:fix/okf-long-title-import

Conversation

@jackmercy

@jackmercy jackmercy commented Jul 18, 2026

Copy link
Copy Markdown

Summary

  • bound explicit foreign OKF titles to MemoryRecord's 100-character limit
  • retain the source title in the supporting-data footer when it must be shortened
  • add a regression test that validates both the long-title row and a valid neighboring row against MemoryRecord

Root cause and impact

map_okf bounded titles inferred from content, but forwarded explicit OKF titles unchanged. MemoryRecord.title rejects values longer than 100 characters, and both batch clients construct every MemoryRecord before storage starts.

As a result, one foreign OKF entry with a 101-character title raises a validation error before any write and causes the migration runner to mark the entire batch as failed, including up to 99 otherwise-valid neighboring entries.

The mapper now shortens only the schema-bound title field and records the original value in supporting data, so the batch remains valid without silently discarding the source title.

Submission for #770.

Validation

  • uv run pytest -q (full suite passed; 24 live E2E tests skipped because no API key was configured)
  • uv run ruff check .
  • uv run mypy memanto
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes
    • Improved imported memory title handling by enforcing length limits.
    • Preserved overlong original titles in supporting data while displaying a shortened title.
    • Ensured imports with long foreign titles remain valid and can be processed correctly.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f7775b9-432e-45be-8046-55f8b8201b8d

📥 Commits

Reviewing files that changed from the base of the PR and between 32d83bd and 3ecc69f.

📒 Files selected for processing (2)
  • memanto/cli/migrate/mappers.py
  • tests/test_okf.py

📝 Walkthrough

Walkthrough

OKF migration now truncates derived and explicit titles through shared limits, conditionally preserves overlong original titles in supporting data, and validates imported rows with a regression test.

Changes

OKF title mapping

Layer / File(s) Summary
Centralized title limits and OKF mapping
memanto/cli/migrate/mappers.py
Adds shared title sizing constants and truncation logic, applies the limit to derived and OKF titles, and conditionally records overlong original titles.
Long-title import validation
tests/test_okf.py
Verifies overlong foreign titles are truncated, original titles remain in content, and imported rows construct valid MemoryRecord objects.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: het0814

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving OKF batch imports when titles are too long.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jackmercy
jackmercy marked this pull request as ready for review July 18, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant