{"record":{"id":"4e89a338f814d582","repo":"vercel/next.js","slug":"missing-weight-for-available-weights","errorCode":null,"errorMessage":"Missing weight for {}. Available weights: {}","messagePattern":"Missing weight for (.+?)\\. Available weights: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/next-core/src/next_font/google/options.rs","lineNumber":107,"sourceCode":"        .weight\n        .map(|w| match w {\n            OneOrManyStrings::One(one) => fxindexset![one],\n            OneOrManyStrings::Many(many) => many.into_iter().collect(),\n        })\n        .unwrap_or_default();\n\n    let mut styles = argument\n        .style\n        .map(|w| match w {\n            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 {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/crates/next-core/src/next_font/google/options.rs#L89-L125","documentation":"Thrown by options_from_request() when no weight is specified for a Google font that is NOT a variable font (i.e. its available weights list does not contain 'variable'). Non-variable fonts require an explicit weight because there is no default axis range to fall back to.","triggerScenarios":"Calling a non-variable Google font without a `weight` property, e.g. `Roboto({ subsets: ['latin'] })` where Roboto in the fetched font data has no 'variable' entry. The validator checks supports_variable_weight and bails when weights are empty and the font isn't variable.","commonSituations":"Copying a variable-font example (which omits weight) onto a non-variable font; assuming a default weight exists; the font metadata doesn't list 'variable'.","solutions":["Add an explicit `weight` property matching one of the listed available weights.","Switch to a variable variant of the font (one whose available weights include 'variable') if you want to omit weight.","Re-check the available weights in the error message and pick a valid value."],"exampleFix":"// before\nconst font = Roboto({ subsets: ['latin'] })\n// after\nconst font = Roboto({ subsets: ['latin'], weight: '400' })","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["For non-variable fonts, always specify a valid weight.","Use 'variable' weight only for fonts that offer a variable variant.","Copy the available-weights list from the font's Google Fonts page."],"tags":["next-font","google-font","font","weight","rust"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}