ENG-2145 Utility function to discover importable relations and schemas before node import - #1301
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
71badcf to
97993ea
Compare
97993ea to
7bfedb4
Compare
7bfedb4 to
9d2a93d
Compare
9d2a93d to
828f8da
Compare
828f8da to
a2ee135
Compare
a2ee135 to
62c2310
Compare
| .select() | ||
| .in("id", [...nodeTypeSchemaIds]); | ||
| if (nsError) throw nsError; | ||
| if (!nodeTypeSchemaIds) throw new Error("Missing relation type schemas"); |
There was a problem hiding this comment.
Wrong variable being checked. nodeTypeSchemaIds is a Set which is always truthy, so this guard will never trigger. Should check dbNodeTypeSchemas instead:
if (!dbNodeTypeSchemas) throw new Error("Missing node type schemas");This means if the database query fails silently or returns null, the code will continue with undefined and crash later when trying to iterate over it.
| if (!nodeTypeSchemaIds) throw new Error("Missing relation type schemas"); | |
| if (!dbNodeTypeSchemas) throw new Error("Missing node type schemas"); |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
| triplesBySchemaId[ | ||
| ((c.reference_content ?? {}) as Record<string, number>)["relation_type"] | ||
| ].push(c as Concept); |
There was a problem hiding this comment.
Undefined array access will crash. If relation_type is undefined in the triple's reference_content, this accesses triplesBySchemaId[undefined] which returns undefined, then calls .push() on undefined causing a runtime error.
data.forEach((c) => {
const relationType = ((c.reference_content ?? {}) as Record<string, number>)["relation_type"];
if (relationType !== undefined && triplesBySchemaId[relationType]) {
triplesBySchemaId[relationType].push(c as Concept);
}
});| triplesBySchemaId[ | |
| ((c.reference_content ?? {}) as Record<string, number>)["relation_type"] | |
| ].push(c as Concept); | |
| const relationType = ((c.reference_content ?? {}) as Record<string, number>)["relation_type"]; | |
| if (relationType !== undefined && triplesBySchemaId[relationType]) { | |
| triplesBySchemaId[relationType].push(c as Concept); | |
| } | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
62c2310 to
e728391
Compare
e728391 to
825652b
Compare
https://linear.app/discourse-graphs/issue/ENG-2145/utility-function-to-discover-importable-relations-and-schemas-before
https://www.loom.com/share/df8155a2b15446e7b650574591b6a89c