fix: Prevent FK constraint failure from nodes with empty names#62
Merged
colbymchenry merged 1 commit intomainfrom Mar 18, 2026
Merged
fix: Prevent FK constraint failure from nodes with empty names#62colbymchenry merged 1 commit intomainfrom
colbymchenry merged 1 commit intomainfrom
Conversation
Fixes #42 — tree-sitter can produce nodes with empty names (e.g. from complex C/C++ declarators in header files). These nodes were silently skipped at DB insert time, but their containment edges were still inserted, causing a FOREIGN KEY constraint violation that crashed indexing. Two-layer fix: - createNode() now returns null for empty names, preventing the node and its edges from ever being created (Option A) - storeExtractionResult() filters edges and unresolved refs to only reference nodes that passed validation, as a safety net (Option B)
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.
Summary
Fixes #42 —
FOREIGN KEY constraint failedwhen indexing C/C++ header files.Root cause: Tree-sitter can produce function nodes with empty names from complex C/C++ declarators (e.g. macro-generated declarations in
.hfiles). These nodes were silently skipped byinsertNode()validation, but their containment edges were still inserted into the database — causing a FK violation since the target node didn't exist.Two-layer fix:
createNode()now returnsnullfor empty names, preventing the node and its containment edges from ever being created. All 7 callers that use the return value handle thenullcase.storeExtractionResult()now filters edges and unresolved references to only include those referencing nodes that passed validation, preventing any future FK violations from similar edge cases.Test plan
.hfiles)