Skip to content

fix(manual-import): post memories to the v2 integration import route - #14343

Closed
Suyann wants to merge 1 commit into
BasedHardware:mainfrom
Suyann:fix/manual-import-memories-route
Closed

Suyann wants to merge 1 commit into
BasedHardware:mainfrom
Suyann:fix/manual-import-memories-route

Conversation

@Suyann

@Suyann Suyann commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What

The manual import app (plugins/import/manual-import) now posts extracted memories to the Integration Import route the backend serves, POST /v2/integrations/{app_id}/user/memories?uid=, instead of /v2/integrations/{app_id}/user/facts, which is not a route and returns 404 in production. Fixes #14341.

Why

backend/routers/integration.py has no /user/facts handler; memories are created at /user/memories. The app's comments claimed the API "still uses facts", so every memory in every import came back ❌ ERROR: Status code 404 and nothing was ever stored. Live proof (no key needed — a missing route 404s, a real route asks for the key):

POST https://api.omi.me/v2/integrations/testapp/user/facts?uid=u1      -> 404 {"detail":"Not Found"}
POST https://api.omi.me/v2/integrations/testapp/user/memories?uid=u1   -> 401 Missing or invalid Authorization header

The backend's own public-contract test says it explicitly (backend/tests/unit/test_integration_public_contract.py:27-29): "/v2/integrations/{app_id}/user/facts is intentionally absent: memories and facts are the same concept on the backend and are served by /user/memories (POST)."

The request body the app already sends ({"text": ..., "text_source": "other", "text_source_spec": "learning_notes"}) matches the v2 route's ExternalIntegrationCreateMemory model, so only the path changes.

Changes

  • plugins/import/manual-import/app.py: API_URL → /v2/integrations/{app_id}/user/memories; the two stale "facts" comments are corrected. No behaviour change beyond the path.
  • plugins/import/manual-import/test_submit_memories_route.py (new): hermetic regression test — stubs flask, requests, openai, httpx, dotenv, loads the real app.py, drives submit_memories() end to end with rule-based extraction, and pins the outgoing URL, bearer header and text payload; also asserts a request without uid is rejected with 400 and makes no HTTP call.
  • .github/checks-manifest.yaml: registers manual-import-memories-route-tests (local + ci lanes, triggered by plugins/import/manual-import/**).

Relationship to #13659: that PR URL-encodes uid in the requests.post call of this same file; this PR changes only the API_URL constant and comments above it. They merge cleanly in either order.

Tests

PYTHONUTF8=1 python3 plugins/import/manual-import/test_submit_memories_route.py
PASS test_api_url_is_the_v2_user_memories_route
PASS test_submit_posts_each_memory_to_the_memories_route
PASS test_submit_without_uid_makes_no_request
3 tests passed

Same test against the previous app.py fails as intended:

FAIL test_api_url_is_the_v2_user_memories_route: https://api.omi.me/v2/integrations/01JPP8Y2PA2YWQPTMDAFHXWX8E/user/facts
FAIL test_submit_posts_each_memory_to_the_memories_route: https://api.omi.me/v2/integrations/01JPP8Y2PA2YWQPTMDAFHXWX8E/user/facts?uid=user-42

Also run: python3 plugins/oauth/test_client_log_safety.py (OK, 5 tests), git diff --check (clean). A full live import needs a real integration API key for the app, which I do not have; the route itself was exercised live with the curl calls above.

Failure-Class

Failure-Class: none

(scripts/failure-class prepare lists no registry class for a client hard-coding a route the server does not serve.)

Invariants

scripts/pr-preflight --suggest reports no affected product invariants for this diff (plugin-only change).

Bounty

Claims the US$25 proposed in #14341; payout details will be sent to [email protected] after merge as the Contribution guide asks.

Authored with Claude Code on behalf of @Suyann; every command listed was actually run on this branch.

Review in cubic

The manual import app built its API_URL as
/v2/integrations/{app_id}/user/facts, a path the backend does not serve
(curl -X POST https://api.omi.me/v2/integrations/x/user/facts?uid=u -> 404
"Not Found"), so every extracted memory came back 404 and nothing was
imported. The Integration Import API (backend/routers/integration.py,
docs/doc/developer/apps/Import.mdx) creates memories at
POST /v2/integrations/{app_id}/user/memories?uid=, which answers 401 for a
missing key rather than 404. The request payload ({"text": ...}) already
matched that route, so only the path changes; stale "facts" comments are
updated alongside.

Adds a hermetic regression test that stubs flask/requests/openai/httpx and
drives submit_memories() end to end, pinning the route, and registers it in
the checks manifest.

Verification:
- PYTHONUTF8=1 python3 plugins/import/manual-import/test_submit_memories_route.py -> 3 tests passed
- same test against the previous app.py -> 2 FAIL (url .../user/facts)

Failure-Class: none

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual-import route fix: root cause with live curl proof, fixes #14341, scoped (162 lines), tests pin the fix and fail on old code = 5/5. mergeStateStatus UNKNOWN after refetch -- approve only per override b.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified against the backend — this fix is correct, and nicely done.

What I checked:

  • backend/routers/integration.py has exactly one user-scoped memory-creation route, POST /v2/integrations/{app_id}/user/memories (required uid query param, Authorization: Bearer header), and no /user/facts handler anywhere in the router. The backend's own contract test (backend/tests/unit/test_integration_public_contract.py) documents that /user/facts is intentionally absent — so every import from this app was indeed dying on 404, as manual-import: submit_memories posts to /v2/integrations/{app_id}/user/facts, which is not a backend route (404) — every import fails ($25 bounty proposed) #14341 describes.
  • The payload the app already sends ({"text", "text_source": "other", "text_source_spec": "learning_notes"}) matches ExternalIntegrationCreateMemory field-for-field, so only the path needed to change — and app.py changes exactly that plus the two stale "facts" comments. No other behavior is touched.
  • test_submit_memories_route.py is genuinely hermetic (flask/requests/openai/httpx/dotenv stubbed before the real app.py is imported) and pins the right things: the full URL with ?uid=, the Bearer header, text in the body, and that a missing uid returns 400 with zero outbound requests. I ran it in a clean environment: 3/3 pass.
  • .github/checks-manifest.yaml parses cleanly with the new entry registered in the right section (checks:, lanes local+ci) and sensible triggers.

Two maintainer notes (neither blocks this PR):

  • The same dead route lives in a sibling plugin: plugins/composio/src/omi_api.py still builds {API_BASE_URL}/{APP_ID}/user/facts?uid=... (create_fact, line 61), so that integration is presumably 404ing in production the same way. Worth a follow-up issue — @Suyann would be well placed to take it since the fix pattern is identical to this one.
  • plugins/import/manual-import/README.md still brands the tool as the "Smart Facts Collector" with an "Extract & Submit Facts" button. The capability wording is fine (the backend accepts both create_memories and create_facts actions), but the docs read slightly out of date next to the corrected endpoint comments. Cosmetic only.

Fixes a real user-visible outage (every manual import failing with 404) and ships a regression test that exercises the real module rather than a copy. Solid first contribution — thank you!

Feedback by Omi's AI maintainer assistant on behalf of David — flag disagreements, it learns.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Suyann

Suyann commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough verification. Took the composio follow-up you flagged: #14385 fixes the same dead /user/facts route in plugins/composio/src/omi_api.py with the same hermetic-test + manifest pattern (tracking issue #14384). Left the manual-import README wording alone here to keep this PR to the route fix.

@Suyann

Suyann commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Closing: main now carries this fix (API_URL points at /user/memories, landed via c11be9d and #14341 is closed). Thanks for the review.

@Suyann Suyann closed this Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey @Suyann 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

3 participants