{"record":{"id":"ed5db8a88b7b0628","repo":"slint-ui/slint","slug":"mode-mismatch-for-variable-variable-name-using-fallback","errorCode":null,"errorMessage":"Mode mismatch for variable ${variable.name}: using fallback value from mode ${foundModeId} (index ${valueIndex}) for expected mode ${modeName}","messagePattern":"Mode mismatch for variable (.+?): using fallback value from mode (.+?) \\(index (.+?)\\) for expected mode (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"tools/figma-inspector/backend/utils/export-variables.ts","lineNumber":1034,"sourceCode":"                                if (availableValues.length > 0) {\n                                    // Try to map collection modes to different variable modes when possible\n                                    // Get the index of this collection mode\n                                    const collectionModeIndex =\n                                        collection.modes.findIndex(\n                                            (mode) =>\n                                                mode.modeId ===\n                                                collectionMode.modeId,\n                                        );\n\n                                    // Use different available values for different collection modes\n                                    const valueIndex = Math.min(\n                                        collectionModeIndex,\n                                        availableValues.length - 1,\n                                    );\n                                    [foundModeId, value] =\n                                        availableValues[valueIndex];\n\n                                    console.warn(\n                                        `Mode mismatch for variable ${variable.name}: using fallback value from mode ${foundModeId} (index ${valueIndex}) for expected mode ${modeName}`,\n                                    );\n                                }\n                            }\n                        }\n\n                        // Skip if no value found at all\n                        if (value === null) {\n                            console.warn(\n                                `No value found for variable ${variable.name} in mode ${modeName}`,\n                            );\n                            continue;\n                        }\n\n                        // Format value and resolve all references immediately\n                        let formattedValue = \"\";\n                        let comment: string | undefined;\n","sourceCodeStart":1016,"sourceCodeEnd":1052,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/tools/figma-inspector/backend/utils/export-variables.ts#L1016-L1052","documentation":"During Figma variable export, the value for the requested mode was not found, but the variable had values for other modes. The exporter falls back to a value from a different mode (clamping the index into availableValues) and warns which mode the fallback came from, so output colors/text may not match the requested mode.","triggerScenarios":"exportFigmaVariablesToSeparateFiles resolves a variable per mode; the mode's value is absent (mode mismatch between the requested modeName and the variable's published modes), so a fallback index is computed.","commonSituations":"A variable was not published in every mode of its collection; new modes were added in Figma while some variables were not updated; export requests a mode id that the variable doesn't define.","solutions":["Publish the variable in every mode of its collection in Figma","Ensure the requested modeName/mode id actually exists on the variable's collection","Re-run export after refreshing the Figma variables snapshot","Treat the warning as a data audit: enumerate variables lacking the mode and fix them at source"],"exampleFix":"// before\n[foundModeId, value] = availableValues[valueIndex]; // silent-ish fallback\n// after\nif (!availableValues.some(([id]) => id === expectedModeId)) {\n  throw new Error(`Variable ${variable.name} has no value for mode ${modeName}`);\n}","handlingStrategy":"validation","validationCode":"const modeValue = availableValues.find(([id]) => id === expectedModeId);\nif (!modeValue) throw new Error(`Variable ${variable.name} missing mode ${modeName}`);","typeGuard":"function hasModeValue(v: { valuesByMode: Record<string, unknown> }, modeId: string): boolean {\n  return Object.prototype.hasOwnProperty.call(v.valuesByMode, modeId);\n}","tryCatchPattern":"try {\n  formatVariableValue(variable, modeName);\n} catch (e) {\n  exportInfo.errors.add(e.message); // track mismatches instead of falling back silently\n}","preventionTips":["Publish every variable in all collection modes in Figma","Validate mode coverage for all variables before starting the export","Refresh the Figma variable snapshot after any mode changes"],"tags":["figma","variables","mode-mismatch","fallback"],"backgroundTag":"value-out-of-range","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"}