[integrations] smart-ingest: handle UUID thought/job ids#367
Open
alanshurafa wants to merge 2 commits into
Open
[integrations] smart-ingest: handle UUID thought/job ids#367alanshurafa wants to merge 2 commits into
alanshurafa wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
The merged
integrations/smart-ingestEdge Function was ported from a codebase that used bigint thought and job ids. On an Open Brain install — wherethoughts.idand the smart-ingest tables (ingestion_jobs,ingestion_items, plusjob_id,matched_thought_id,result_thought_id) are all UUIDs — the integration parsed those ids as numbers and broke at runtime:extractThoughtIdonly acceptednumber, so a successfulupsert_thoughtreturning a UUID looked like a failure (upsert_thought returned no thought_id)./smart-ingest/executedidtypeof body.job_id === "number" ? … : 0, so a UUIDjob_idwas rejected with a 400.open-brain-dashboard-proingest routes validated the id as a positive integer (Number.isInteger(idNum) && idNum > 0), rejecting every UUID withInvalid id.This converts every DB id field in the ingestion path from
numbertostring.Changes
integrations/smart-ingest/index.tsextractThoughtIdaccepts a non-empty UUID string (bare, or wrapped as{ thought_id }/{ id }).handleExecuteJobaccepts a UUIDjob_idand validates its shape.createJob,updateJobById,persistItems,executeItemsignatures and theIngestionItem/IngestionJob/UpsertThoughtResulttypes use string ids; empty-string sentinel replaces the0sentinel for "no id".Dashboards (
open-brain-dashboard-proandopen-brain-dashboard-next)proingest routes (app/api/ingest/[id]/route.ts,[id]/execute/route.ts) validate a UUID instead of a positive integer.lib/types.ts, thetriggerIngestreturn type inlib/api.ts, andfetchJobDetail's parameter incomponents/AddToBrain.tsxare string.The
nextingest routes already forwarded the id untouched, so only their types needed aligning.Scope
Ingestion path only. The broader dashboard assumption that
thoughts.idis 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.