{"record":{"id":"bed817181f8b79fe","repo":"warpdotdev/warp","slug":"createsemantictokens-mode-modename-not-found","errorCode":null,"errorMessage":"createSemanticTokens: mode \"${modeName}\" not found in modeIds for token \"${token.name}\". Available modes: ${Object.keys(modeIds).join(', ')}","messagePattern":"createSemanticTokens: mode \"(.+?)\" not found in modeIds for token \"(.+?)\"\\. Available modes: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"resources/bundled/mcp_skills/figma/figma-generate-library/scripts/createSemanticTokens.js","lineNumber":46,"sourceCode":" */\nasync function createSemanticTokens(collection, modeIds, tokenMap, runId) {\n  const variables = {}\n\n  for (const token of tokenMap) {\n    // Create the variable\n    const variable = figma.variables.createVariable(token.name, collection, token.type)\n\n    // Tag for cleanup\n    variable.setPluginData('dsb_key', `variable/${token.name}`)\n    if (runId) {\n      variable.setPluginData('dsb_run_id', runId)\n    }\n\n    // Set values for each mode\n    for (const [modeName, rawValue] of Object.entries(token.values)) {\n      const modeId = modeIds[modeName]\n      if (!modeId) {\n        throw new Error(\n          `createSemanticTokens: mode \"${modeName}\" not found in modeIds for token \"${token.name}\". ` +\n            `Available modes: ${Object.keys(modeIds).join(', ')}`,\n        )\n      }\n\n      let value = rawValue\n\n      // Convert hex strings to Figma RGBA for COLOR type\n      if (token.type === 'COLOR' && typeof rawValue === 'string' && rawValue.startsWith('#')) {\n        value = hexToFigmaColor(rawValue)\n      }\n\n      variable.setValueForMode(modeId, value)\n    }\n\n    // Set scopes (default: empty array = hidden from property pickers / primitives)\n    variable.scopes = token.scopes || []\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/resources/bundled/mcp_skills/figma/figma-generate-library/scripts/createSemanticTokens.js#L28-L64","documentation":"createSemanticTokens.js creates one Figma variable per token and sets a value for each mode, looking the modeId up in the modeIds map produced by createVariableCollection(name, modeNames). The error fires when a token's values object has a key (mode name) with no entry in modeIds — the token file and the collection's modes are out of sync. The message lists the available modes to make the mismatch obvious.","triggerScenarios":"Collection created with modeNames ['Light','Dark'] but token.values keyed 'light'/'dark' (case mismatch); a token referencing a third mode like 'HighContrast' that was never passed to createVariableCollection; a modeIds map built from a different collection than the one the variable was created in.","commonSituations":"Design-token JSON authored separately from the pipeline config; renaming modes in the token file without updating the collection step; token sets copied from another theme system that uses 'default' instead of 'Value'.","solutions":["Align the keys of token.values with the exact modeNames array passed to createVariableCollection (matching is case-sensitive)","Pass the modeIds map returned by createVariableCollection straight into createSemanticTokens instead of rebuilding it","Pre-validate that every key of every token.values exists in modeIds before creating any variable, so a mismatch does not leave a half-built collection behind"],"exampleFix":"// before\nconst { modeIds } = await createVariableCollection('Color', ['Light', 'Dark'], runId)\nawait createSemanticTokens([\n  { name: 'bg/primary', type: 'COLOR', values: { light: '#ffffff', dark: '#000000' } },\n], modeIds) // throws: mode \"light\" not found in modeIds\n\n// after\nconst { modeIds } = await createVariableCollection('Color', ['Light', 'Dark'], runId)\nawait createSemanticTokens([\n  { name: 'bg/primary', type: 'COLOR', values: { Light: '#ffffff', Dark: '#000000' } },\n], modeIds)","handlingStrategy":"validation","validationCode":"const modes = Object.keys(modeIds)\nfor (const token of tokens) {\n  for (const modeName of Object.keys(token.values)) {\n    if (!(modeName in modeIds)) {\n      throw new Error(`token ${token.name} references unknown mode \"${modeName}\"; collection has: ${modes.join(', ')}`)\n    }\n  }\n}\nawait createSemanticTokens(tokens, modeIds, runId)","typeGuard":"function modesCovered(token, modeIds) {\n  return Object.keys(token.values).every((m) => m in modeIds)\n}","tryCatchPattern":"try {\n  await createSemanticTokens(tokens, modeIds, runId)\n} catch (err) {\n  if (err instanceof Error && err.message.includes('not found in modeIds')) {\n    // re-align token.values keys with the collection's modeNames, then re-run\n  }\n  throw err\n}","preventionTips":["Derive modeNames and token.values keys from the same config source","Pass createVariableCollection's returned modeIds through verbatim","Treat mode names as case-sensitive API contracts in lint checks"],"tags":["figma","design-tokens","validation","variables"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}