Skip to content

[integrations] smart-ingest: handle UUID thought/job ids#367

Open
alanshurafa wants to merge 2 commits into
NateBJones-Projects:mainfrom
alanshurafa:contrib/alanshurafa/smart-ingest-uuid-ids
Open

[integrations] smart-ingest: handle UUID thought/job ids#367
alanshurafa wants to merge 2 commits into
NateBJones-Projects:mainfrom
alanshurafa:contrib/alanshurafa/smart-ingest-uuid-ids

Conversation

@alanshurafa

Copy link
Copy Markdown
Collaborator

What this changes

The merged integrations/smart-ingest Edge Function was ported from a codebase that used bigint thought and job ids. On an Open Brain install — where thoughts.id and the smart-ingest tables (ingestion_jobs, ingestion_items, plus job_id, matched_thought_id, result_thought_id) are all UUIDs — the integration parsed those ids as numbers and broke at runtime:

  • extractThoughtId only accepted number, so a successful upsert_thought returning a UUID looked like a failure (upsert_thought returned no thought_id).
  • /smart-ingest/execute did typeof body.job_id === "number" ? … : 0, so a UUID job_id was rejected with a 400.
  • The open-brain-dashboard-pro ingest routes validated the id as a positive integer (Number.isInteger(idNum) && idNum > 0), rejecting every UUID with Invalid id.

This converts every DB id field in the ingestion path from number to string.

Changes

integrations/smart-ingest/index.ts

  • extractThoughtId accepts a non-empty UUID string (bare, or wrapped as { thought_id } / { id }).
  • handleExecuteJob accepts a UUID job_id and validates its shape.
  • createJob, updateJobById, persistItems, executeItem signatures and the IngestionItem / IngestionJob / UpsertThoughtResult types use string ids; empty-string sentinel replaces the 0 sentinel for "no id".

Dashboards (open-brain-dashboard-pro and open-brain-dashboard-next)

  • pro ingest routes (app/api/ingest/[id]/route.ts, [id]/execute/route.ts) validate a UUID instead of a positive integer.
  • Ingestion id fields in lib/types.ts, the triggerIngest return type in lib/api.ts, and fetchJobDetail's parameter in components/AddToBrain.tsx are string.

The next ingest routes already forwarded the id untouched, so only their types needed aligning.

Scope

Ingestion path only. The broader dashboard assumption that thoughts.id is numeric (thought-detail, connections, duplicate-resolve, and delete-audit routes) is left for a separate thoughts-UUID pass — it does not affect the smart-ingest flow.

Testing

Pure type and validation changes; no data or seed touched. Verified by inspection that no number-typed id field remains in the ingestion path and that the empty-string sentinels preserve the original truthiness behavior. Pairs with the smart-ingest-tables schema so the integration completes a job end-to-end on a UUID install.

alanshurafa and others added 2 commits June 13, 2026 14:38
The integration was ported from a bigint-id codebase and parsed thought
and job ids as numbers. On Open Brain (UUID primary keys) that breaks at
runtime: upsert_thought returns a UUID that extractThoughtId rejects as
"no thought_id", /execute 400s on a UUID job_id, and the pro dashboard's
ingest routes reject every UUID with a positive-integer guard.

Convert every ingestion id field (integration + both dashboards) from
number to string, validate job ids as UUIDs, and replace the 0 "no id"
sentinel with an empty string. Pairs with the smart-ingest-tables schema
so a job completes end to end on a fresh UUID install.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Post-UUID conversion, the integer job_id examples return 400 ("must be a UUID"). Align the docs with the handler's UUID_RE check.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added dashboard Contribution: frontend template integration Contribution: MCP extension or capture source labels Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard Contribution: frontend template integration Contribution: MCP extension or capture source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant