Skip to content

fix(composio): post synced memories to the v2 integration import route - #14385

Closed
Suyann wants to merge 3 commits into
BasedHardware:mainfrom
Suyann:fix/composio-memories-route
Closed

Suyann wants to merge 3 commits into
BasedHardware:mainfrom
Suyann:fix/composio-memories-route

Conversation

@Suyann

@Suyann Suyann commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What

create_fact() in the Composio/Notion sync plugin now posts 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 #14384. Follow-up to #14343, where the maintainer review flagged this sibling occurrence.

Why

backend/routers/integration.py has no /user/facts handler; memories are created at /user/memories. 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)." Every memory the plugin tried to sync therefore came back 404 (logged as Error creating fact: HTTPError, Response status: 404) and create_fact returned False, so /api/omi/facts, /api/omi/facts/batch and process_pending_memories all failed silently. 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 payload the plugin already sends ({"text", "text_source", "text_source_spec"}) matches the v2 route's ExternalIntegrationCreateMemory model, so only the path changes.

Changes

  • plugins/composio/src/omi_api.py: URL /user/facts → /user/memories (comment explains why). No other behaviour is touched; the plugin's own /api/omi/facts endpoints keep their names.
  • plugins/composio/test_omi_api_route.py (new): hermetic regression test — stubs fastapi, pydantic, requests, dotenv and the sibling .db module, loads the real omi_api.py as a package submodule (so the relative import works), and pins the full URL with ?uid=, the bearer header and the text/text_source/text_source_spec payload; also asserts the retired /user/facts path is never used and that missing credentials raise ValueError without making a request.
  • .github/checks-manifest.yaml: registers composio-omi-memories-route-tests (local + ci lanes, triggered by plugins/composio/**).

Relationship to open #13304 (fix(composio): preserve first-person Notion memories): that PR touches src/notion.py, the README and its own test files, not src/omi_api.py; the only shared touch point is the adjacent manifest insertion before exempt:, a trivial textual conflict if it lands first.

Follow-up commit (from the review on this PR)

create_fact() now clamps a source outside the backend enum (email | social_post | other, backend/models/integrations.py:27) to "other" and keeps the original value in text_source_spec (e.g. "notion_page:notion"), the same provenance pattern store_fact already used. Without this, process_pending_memories (DB source "notion_page") and free-form /api/omi/facts callers would still 422 after the route fix. The happy-path test now asserts a payload the backend accepts, and two new cases cover the clamp and the enum pass-through.

Tests

PYTHONUTF8=1 python3 plugins/composio/test_omi_api_route.py
PASS test_create_fact_posts_to_v2_user_memories_route
PASS test_retired_facts_route_is_never_used
PASS test_missing_credentials_raise_without_request
PASS test_non_enum_source_is_clamped_to_other_with_provenance
PASS test_enum_sources_pass_through_unchanged
5 tests passed

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

FAIL test_create_fact_posts_to_v2_user_memories_route: https://api.omi.me/v2/integrations/app123/user/facts?uid=user-42
FAIL test_retired_facts_route_is_never_used: https://api.omi.me/v2/integrations/app123/user/facts?uid=u

Also run: python3 plugins/oauth/test_client_log_safety.py (OK, 5 tests), git diff --check (clean), bash scripts/pr-preflight --pr-body-file <this body> (see below). A full live sync needs a real integration API key for the composio 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 — same conclusion as #14342/#14343.)

Invariants

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

Bounty

Claims the US$25 proposed in #14384; 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.

create_fact in plugins/composio/src/omi_api.py built its 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"; backend/tests/unit/test_integration_public_contract.py:27-29
says /user/facts is "intentionally absent"). Every Notion/Composio memory
the plugin tried to sync therefore came back 404 and was logged as an
error. The Integration Import API creates memories at
POST /v2/integrations/{app_id}/user/memories?uid=; the request payload
({"text", "text_source", "text_source_spec"}) already matched that route,
so only the path changes. Same defect class as BasedHardware#14343 (manual-import),
flagged there by the maintainer review.

Adds a hermetic regression test that stubs fastapi/pydantic/requests/dotenv
and the sibling .db module, loads the real omi_api.py, and pins the route,
bearer header and payload; registers it in the checks manifest.

Verification:
- PYTHONUTF8=1 python3 plugins/composio/test_omi_api_route.py -> 3 tests passed
- same test against the previous omi_api.py -> 2 FAIL (url .../user/facts)

Failure-Class: none
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified against the backend and the new tests — the core claim checks out, and I ran the hermetic suite locally (3/3 pass).

plugins/composio/src/omi_api.py — create_fact() now posts to POST /v2/integrations/{app_id}/user/memories?uid=…. Confirmed against backend/routers/integration.py:184: that route exists (Bearer-key auth, rate limit, capability check, process_external_integration_memory), and there is no /user/facts handler in the router. backend/tests/unit/test_integration_public_contract.py:27-29 explicitly documents /user/facts as intentionally absent — memories and facts are the same concept server-side. The payload keys (text, text_source, text_source_spec) match ExternalIntegrationCreateMemory in backend/models/integrations.py, so the one-line path change is the right minimal fix. Nice debugging, and the live 404-vs-401 evidence in the description is a good touch.

plugins/composio/test_omi_api_route.py — solid hermetic harness: stdlib-only stubs for fastapi/pydantic/requests/dotenv and the sibling .db module, loads the real omi_api.py via importlib, asserts URL/headers/payload, pins that /user/facts is never used, and checks the missing-credentials path raises before any request. No network, no secrets.

.github/checks-manifest.yaml — composio-omi-memories-route-tests is correctly registered under checks: with triggers covering both plugins/composio/** and the manifest itself.

One residual follow-up worth a follow-up commit (non-blocking for this fix): the backend enum ExternalIntegrationMemorySource only accepts email | social_post | other — anything else 422s. process_pending_memories forwards the DB source ("notion_page" stored by notion.py:396), and /api/omi/facts forwards free-form client text_source, so both can still fail after this fix. Clamping non-enum sources to "other" (as store_fact already does, keeping provenance in source_spec) would finish the job. Also a small test nit: the happy-path test uses source="notion", which the backend enum itself would reject — asserting with "other" would pin a payload the server actually accepts.

Thanks for the clean, well-evidenced fix. Leaving the final merge call to the maintainers since this changes a production integration import path.


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

The backend enum ExternalIntegrationMemorySource accepts email | social_post |
other and rejects anything else with 422. process_pending_memories forwards the
DB source ("notion_page", stored by notion.py) and /api/omi/facts forwards the
client's free-form text_source, so those callers still failed after the route
fix. create_fact now clamps a non-enum source to "other" and keeps the original
value in text_source_spec (same provenance pattern store_fact already used), so
every caller sends a payload the server accepts. The happy-path test now asserts
a payload the backend accepts ("other"), plus two new cases for the clamp and
the enum pass-through.

Verification:
- PYTHONUTF8=1 python3 plugins/composio/test_omi_api_route.py -> 5 tests passed
- the clamp test fails against the previous commit (text_source "notion_page")

Failure-Class: none
@Suyann

Suyann commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Took both follow-ups in a second commit: create_fact() now clamps a non-enum source to "other" and carries the original value in text_source_spec (e.g. "notion_page:notion"), so process_pending_memories and free-form /api/omi/facts callers no longer 422; the happy-path test asserts "other", and two new cases cover the clamp and the enum pass-through (5/5 locally, pr-preflight 15/15). PR description updated accordingly.

@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.

Confidence gate 5/5: real bug (backend serves /v2/integrations/{app_id}/user/memories, not /user/facts -- confirmed via backend/routers/integration.py and the backend's own public-contract test), root cause clear, hermetic regression test added, confirmed not already fixed on main. mergeStateStatus is DIRTY -- per standing policy I do not rebase/force-push PR branches, so holding at approve only. Needs manual rebase before merge.

… in a stable section

Moves the checks-manifest.yaml entry out of the tail of the checks list, where
several concurrent PRs insert at the same spot and every merge conflicts, into
the stable section after desktop-backend-drift-fixtures. No behaviour change;
the check still runs in both lanes with the same triggers.
@Suyann

Suyann commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflict: the only conflicting file was .github/checks-manifest.yaml (several PRs append at the same spot before exempt:). The entry is now registered in a stable section of the checks list (after desktop-backend-drift-fixtures) with the same command, triggers and lanes; no code change. The branch merges cleanly against current main (git merge-tree), the regression test passes, and pr-preflight passes locally.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up verification on the updated head (1d69153): both items from the earlier automated review are resolved, and the post-approval commit checks out.

  • plugins/composio/src/omi_api.py — create_fact() now clamps non-enum sources to "other" with the original provenance kept in text_source_spec (the store_fact pattern), so process_pending_memories forwarding the DB source "notion_page" and free-form /api/omi/facts callers no longer risk a 422. The allowlist matches ExternalIntegrationMemorySource (email | social_post | other) exactly.
  • plugins/composio/test_omi_api_route.py — re-ran the hermetic suite on this head: 5/5 pass, no network or secrets. The clamp and enum pass-through cases pin the actual outbound payload.
  • .github/checks-manifest.yaml — the relocation commit moves composio-omi-memories-route-tests into the stable section after desktop-backend-drift-fixtures: same command, same triggers, same local+ci lanes, exactly one entry (no leftover at the tail). I ran run_checks.py in the ci lane with the PR body: the new check, failure-class-protocol (the Failure-Class: none declaration matches this code-only fix), and product-invariants all pass.

Maintainer note: #14507 opens the same fix on the same files ~10h later; this PR is the original and the further-along one (it also carries the source-clamp follow-up).

No open concerns from automated review — the remaining step is the maintainer merge decision.


by AI on behalf of David

@Git-on-my-level Git-on-my-level added the positive-signal Automation verified a genuine fix/quality contribution label Sep 18, 2026

@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.

Confirmed real 404 route-mismatch bug (composio posting to retired /user/facts), hermetic test, live curl proof, 5/5.

@Suyann

Suyann commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

Closing: #14507 landed on main first and carries both parts of this PR (the /user/memories route and the normalisation of non-enum text_source values), so there is nothing left to merge here. Thanks for the reviews.

@Suyann Suyann closed this Sep 19, 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