{"record":{"id":"f887347214d8cb53","repo":"vercel/next.js","slug":"unexpected-variable-in-weight-array-for-font","errorCode":null,"errorMessage":"Unexpected `variable` in weight array for font {}. You only need `variable`, it includes all available weights.","messagePattern":"Unexpected `variable` in weight array for font (.+?)\\. You only need `variable`, it includes all available weights\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/next-core/src/next_font/google/options.rs","lineNumber":117,"sourceCode":"            OneOrManyStrings::One(one) => vec![one],\n            OneOrManyStrings::Many(many) => many,\n        })\n        .unwrap_or_default();\n\n    let supports_variable_weight = font_data.weights.iter().any(|el| el == \"variable\");\n    let weights = if requested_weights.is_empty() {\n        if !supports_variable_weight {\n            anyhow::bail!(\n                \"Missing weight for {}. Available weights: {}\",\n                font_family,\n                font_data.weights.join(\", \")\n            )\n        }\n\n        FontWeights::Variable\n    } else if requested_weights.contains(\"variable\") {\n        if requested_weights.len() > 1 {\n            anyhow::bail!(\n                \"Unexpected `variable` in weight array for font {}. You only need `variable`, it \\\n                 includes all available weights.\",\n                font_family\n            )\n        }\n\n        FontWeights::Variable\n    } else {\n        for requested_weight in &requested_weights {\n            if !font_data.weights.contains(requested_weight) {\n                anyhow::bail!(\n                    \"Unknown weight {} for font {}.\\nAvailable weights: {}\",\n                    requested_weight,\n                    font_family,\n                    font_data.weights.join(\", \")\n                )\n            }\n        }","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/crates/next-core/src/next_font/google/options.rs#L99-L135","documentation":"Thrown by options_from_request() when the requested weights array contains the string 'variable' alongside other weights. 'variable' already encompasses all available weights of a variable font, so mixing it with explicit weights is contradictory and redundant.","triggerScenarios":"Passing `weight: ['variable', '400']` (or any combination where requested_weights contains 'variable' and has length > 1) to a variable Google font.","commonSituations":"Misunderstanding that 'variable' is a catch-all; copy-pasting a weight list and appending 'variable'; typo in a generated config.","solutions":["Use `weight: 'variable'` alone for a variable font to get all weights.","Or list only explicit numeric weights (omit 'variable') if you want a fixed subset."],"exampleFix":"// before\nconst font = Inter({ subsets: ['latin'], weight: ['variable', '400'] })\n// after\nconst font = Inter({ subsets: ['latin'], weight: 'variable' })","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["When using weight 'variable', pass it alone (not in an array with other weights).","Prefer the string form weight: 'variable' over an array for variable fonts.","If you want specific weights, list them numerically and omit 'variable'."],"tags":["next-font","google-font","font","weight","variable","rust"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}