{"record":{"id":"d2e26bebe172806c","repo":"slint-ui/slint","slug":"getvariablepathstring-collection-not-found-for-variable-id","errorCode":null,"errorMessage":"[getVariablePathString] Collection not found for variable ID: ${variableId}","messagePattern":"\\[getVariablePathString\\] Collection not found for variable ID: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"tools/figma-inspector/backend/utils/property-parsing.ts","lineNumber":367,"sourceCode":"    const variable = await figma.variables.getVariableByIdAsync(variableId);\n    if (variable) {\n        const collection = await figma.variables.getVariableCollectionByIdAsync(\n            variable.variableCollectionId,\n        );\n        if (collection) {\n            const globalName = formatStructName(collection.name);\n            const pathParts = extractHierarchy(variable.name);\n            const slintPath = pathParts.map(sanitizePropertyName).join(\".\");\n            let resultPath = \"\";\n            if (collection.modes.length > 1) {\n                resultPath = `${globalName}.current.${slintPath}`;\n            } else {\n                resultPath = `${globalName}.${slintPath}`;\n            }\n\n            return resultPath;\n        }\n        console.warn(\n            `[getVariablePathString] Collection not found for variable ID: ${variableId}`,\n        );\n    }\n    return null;\n}\n\nexport async function generateSlintSnippet(\n    sceneNode: SceneNode,\n    useVariables: boolean,\n): Promise<string> {\n    const nodeType = sceneNode.type;\n\n    switch (nodeType) {\n        case \"FRAME\":\n            return await generateRectangleSnippet(sceneNode, useVariables);\n        case \"RECTANGLE\":\n        case \"GROUP\":\n            return await generateRectangleSnippet(sceneNode, useVariables);","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/tools/figma-inspector/backend/utils/property-parsing.ts#L349-L385","documentation":"getVariablePathString resolves a Figma variable ID to a Slint global-qualified path (collection name + variable hierarchy). It first looks up the variable, then the variable collection that owns it. This warning is emitted when the variable exists but its owning collection cannot be fetched (getVariableCollectionByIdAsync returned null), in which case the function returns null and the caller silently falls back to a literal value instead of a variable binding.","triggerScenarios":"Calling getVariablePathString (directly or via path/getBorderWidthAndColor/generateRectangleSnippet/generatePathNodeSnippet/generateTextSnippet) with a variableId that resolves to a variable whose variableCollectionId no longer resolves — e.g. the collection was deleted after variables were detached/modified, or the plugin's figma API session cannot access the collection.","commonSituations":"Running the Figma inspector plugin on a file where a variable's collection was deleted or the variable was left orphaned; copying node data between files where the variable reference survives but the collection does not; Figma API inconsistencies where getVariableByIdAsync succeeds but getVariableCollectionByIdAsync fails.","solutions":["Open the Figma file and check the variable's owning collection in Local variables / library; restore or re-create the deleted collection.","Re-apply the variable to the node so variableCollectionId points at an existing collection.","Accept the fallback: the function returns null and callers use the resolved literal value instead of a variable binding — verify the generated snippet is acceptable.","Update the plugin / Figma desktop app in case this is a stale API session returning null collections."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const variable = await figma.variables.getVariableByIdAsync(variableId);\nconst collection = variable\n    ? await figma.variables.getVariableCollectionByIdAsync(variable.variableCollectionId)\n    : null;\nif (!variable || !collection) {\n    console.warn(`Variable ${variableId} unresolvable; will use literal value`);\n}","typeGuard":"function hasCollection(v: Variable | null): v is Variable & { variableCollectionId: string } {\n    return v != null && typeof v.variableCollectionId === 'string' && v.variableCollectionId.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always treat getVariablePathString's null return as 'use the literal value' — never assume a variable binding exists.","Keep Figma libraries/collections intact; audit detached or deleted variable collections before running the exporter.","Log the variable ID in the null branch to make orphaned variables traceable."],"tags":["figma","variables","null-lookup","plugin"],"backgroundTag":"entity-not-found","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}