Skip to content

eng-1344 f10b upload obsidian relations and their schemas#721

Open
maparent wants to merge 5 commits intomainfrom
eng-1344-upload-relation-and-rel-schema
Open

eng-1344 f10b upload obsidian relations and their schemas#721
maparent wants to merge 5 commits intomainfrom
eng-1344-upload-relation-and-rel-schema

Conversation

@maparent
Copy link
Collaborator

@maparent maparent commented Jan 22, 2026

This uploads relationship schemas to supabase.


Open with Devin

@linear
Copy link

linear bot commented Jan 22, 2026

@supabase
Copy link

supabase bot commented Jan 22, 2026

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@maparent maparent force-pushed the eng-1343-f10a-sync-node-schema-definitions branch from 6bfab2f to 408ef40 Compare January 24, 2026 15:54
@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch 2 times, most recently from f966a5b to 7f0a45d Compare January 24, 2026 18:30
@maparent maparent force-pushed the eng-1343-f10a-sync-node-schema-definitions branch from 5fdb70d to 0b3d0cb Compare January 25, 2026 15:07
@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch 2 times, most recently from 3d49688 to 3b0a73a Compare January 25, 2026 15:21
@maparent maparent force-pushed the eng-1343-f10a-sync-node-schema-definitions branch from 3fb53ae to f661f0f Compare January 27, 2026 17:08
@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch from 3b0a73a to 6c48b9f Compare January 27, 2026 17:11
@maparent maparent force-pushed the eng-1343-f10a-sync-node-schema-definitions branch from f661f0f to df19c3c Compare January 27, 2026 19:25
Base automatically changed from eng-1343-f10a-sync-node-schema-definitions to main January 27, 2026 19:27
@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch 3 times, most recently from ea45b20 to 9e74420 Compare February 1, 2026 21:59
@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch from 9e74420 to 63c0832 Compare February 5, 2026 15:37
maparent added a commit that referenced this pull request Feb 5, 2026
trangdoan982 pushed a commit that referenced this pull request Feb 7, 2026
trangdoan982 pushed a commit that referenced this pull request Feb 8, 2026
maparent added a commit that referenced this pull request Feb 8, 2026
trangdoan982 pushed a commit that referenced this pull request Feb 8, 2026
@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch from 63c0832 to 982652f Compare February 11, 2026 00:51
@maparent maparent marked this pull request as ready for review February 11, 2026 18:52
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review

trangdoan982 added a commit that referenced this pull request Feb 11, 2026
#722)

* eng-1344 f10b upload obsidian relations and their schemas

* current progress

* feature finished

* address PR comments

* address PR comments

* remove local test file

* curr progress

* revert what is handled in #721

* Use SpaceURI rather than spaceId in frontmatter

* address PR comments

* address PR comments

* cleanup

* Update apps/obsidian/src/utils/importNodes.ts

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* normalize on using numbers for dates

* correction

* apply ctime, mtime to assets

* spurious log

* Preserve ctime, mtime in processFrontMatter. Also timezone correction

* add lastModified in frontMatter

* make sure import image works

* add recursive folder creation

* modify the fetchNodeContent flow; simplify the pathMapping

* WIP: shuffle the filePath around

* send originalPathDepth

* actually send path itself

* clarify var name

* make sure fileImport works for all possible settings

* store relative path when rewrite the wikilink instead of default to fileToLinkText

* cleanup logs

* nit

* AI corrections

* Update apps/obsidian/src/utils/importNodes.ts

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* address PR comments

---------

Co-authored-by: Marc-Antoine Parent <maparent@acm.org>
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch 2 times, most recently from e82b16b to 376b1a4 Compare February 11, 2026 23:20
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 10 additional findings in Devin Review.

Open in Devin Review

relationType;
return {
space_id: context.spaceId,
name: label,
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 discourseRelationTypeToLocalConcept uses non-unique label as concept name, causing upsert failure and cascading errors

The new discourseRelationTypeToLocalConcept function sets name: label where label is the user-facing display label of a relation type (e.g., "Supports", "Opposes"). This can collide with the unique constraint concept_space_and_name_idx on (space_id, name) in the database.

Root Cause and Cascading Failure

The database enforces CREATE UNIQUE INDEX concept_space_and_name_idx ON public."Concept" (space_id, name); (packages/database/supabase/schemas/concept.sql:87). Node type schemas are created with name: name (the node type's name) in discourseNodeSchemaToLocalConcept (apps/obsidian/src/utils/conceptConversion.ts:47). The new relation type concepts use name: label at line 77.

If a relation type's label matches any node type's name (e.g., both named "Evidence"), or if two relation types share the same label, only one concept can be inserted. The SQL upsert_concepts function handles this with RETURN NEXT -1 (packages/database/supabase/schemas/concept.sql:379), so the relation type concept silently fails to insert.

The real problem is cascading: discourseRelationSchemaToLocalConcept at line 127 puts relation_type: relationshipTypeId in local_reference_content. When the SQL function _local_concept_to_db_concept processes this, it does SELECT cpt.id INTO STRICT ref_single_val FROM public."Concept" AS cpt WHERE cpt.source_local_id = ... (packages/database/supabase/schemas/concept.sql:316-318). Since the relation type concept was never inserted (due to the name collision), INTO STRICT throws an unhandled exception, aborting the entire upsert_concepts call and failing all remaining concepts in the batch.

Impact: Any name collision between a relation type label and a node type name (or between two relation type labels) causes the entire concept sync to fail, preventing all node and relation data from being uploaded to Supabase.

The Roam version avoids this by using name: getPageTitleByPageUid(relation.id) (apps/roam/src/utils/conceptConversion.ts:125), which yields a unique identifier.

Suggested change
name: label,
name: `${id}-${label}`,
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch from d406e78 to 0f8912b Compare February 11, 2026 23:48
@maparent maparent force-pushed the eng-1344-upload-relation-and-rel-schema branch from 0f8912b to 13b342e Compare February 12, 2026 18:52
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