{"record":{"id":"29b732dbd86649fe","repo":"CherryHQ/cherry-studio","slug":"theme-contract-product-declaration-name-has-i","errorCode":null,"errorMessage":"[theme-contract] product ${declaration.name} has invalid dependency ${reference}","messagePattern":"\\[theme-contract\\] product (.+?) has invalid dependency (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/scripts/validate-theme-contract.ts","lineNumber":288,"sourceCode":"  }\n\n  for (const declaration of extractDeclarations(sources.shadcn, 'shadcn.css')) {\n    if (declaration.name.startsWith(runtimeVariablePrefix)) {\n      throw new Error(`[theme-contract] shadcn.css cannot own runtime input ${declaration.name}`)\n    }\n    for (const reference of extractReferences(declaration.value, declaration.source)) {\n      if (productVariables.has(reference) || reference.startsWith('--color-') || reference.startsWith('--app-')) {\n        throw new Error(`[theme-contract] Shadcn ${declaration.name} cannot depend on product/adapter ${reference}`)\n      }\n    }\n  }\n\n  for (const declaration of extractDeclarations(sources.product, 'product.css')) {\n    for (const reference of extractReferences(declaration.value, declaration.source)) {\n      const validNamespace =\n        reference.startsWith('--cs-') || officialVariables.has(reference) || productVariables.has(reference)\n      if (!validNamespace) {\n        throw new Error(`[theme-contract] product ${declaration.name} has invalid dependency ${reference}`)\n      }\n    }\n  }\n}\n\nfunction assertCatalogCoverage(sources: ThemeContractSources): void {\n  const requiredNames = [\n    ...RUNTIME_THEME_INPUT_TOKENS.map((token) => `--cs-theme-${token}`),\n    ...SHADCN_VARIABLE_TOKENS.map((token) => `--${token}`),\n    ...CHERRY_PRODUCT_VARIABLE_TOKENS.map((token) => `--${token}`)\n  ]\n  const missing = requiredNames.filter((name) => !sources.variableCatalog.includes(`\\`${name}\\``))\n\n  if (missing.length > 0) {\n    throw new Error(`[theme-contract] variable catalog is missing: ${missing.join(', ')}`)\n  }\n}\n","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/packages/ui/scripts/validate-theme-contract.ts#L270-L306","documentation":"Thrown by assertLayerDependencies when a declaration in product.css references a variable outside the allowed product-layer namespaces. Product variables may only reference --cs-* (foundation), official Shadcn variables (--background, --primary, etc.), or other product variables. Any other reference (e.g. --color-*, --app-*, or an undeclared name) is invalid.","triggerScenarios":"`--link: var(--app-accent);` (host-local); `--link: var(--color-blue-500);` (Tailwind adapter); `--link: var(--some-random);` (undeclared).","commonSituations":"Repointing a product token at a Tailwind utility color or a host-injected variable during a redesign; typos in var() references.","solutions":["Re-point the product variable at a valid namespace: a --cs-* foundation var, an official Shadcn var, or another product var.","If you need a concrete color, declare it as a --cs-* primitive in foundation first, then reference that.","Re-run `pnpm --filter @cherrystudio/ui theme:check`."],"exampleFix":"// before (product.css)\n--link: var(--color-blue-500);\n// after — reference a foundation primitive\n--link: var(--cs-blue-600);","handlingStrategy":"validation","validationCode":"// product.css references must stay in --cs-*, shadcn, or product namespaces.\nconst valid = (ref: string) => ref.startsWith('--cs-') || SHADCN_VARIABLE_TOKENS.includes(ref.slice(2) as never) || CHERRY_PRODUCT_VARIABLE_TOKENS.includes(ref.slice(2) as never)\nfor (const [, ref] of sources.product.matchAll(/var\\(\\s*(--[a-z0-9-]+)/g)) {\n  if (!valid(ref)) throw new Error(`product has invalid dependency ${ref}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateThemeContractSources(sources)\n} catch (error) {\n  if (error instanceof Error && /product .* has invalid dependency/.test(error.message)) {\n    console.error(error.message)\n    process.exitCode = 1\n    return\n  }\n  throw error\n}","preventionTips":["product.css may reference --cs-*, official Shadcn vars, or other product vars — nothing else.","Need a literal color? Declare a --cs-* primitive in foundation first, then reference it.","Run theme:check after editing product.css."],"tags":["theme-contract","css","build","validation","layering"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}