vercel/next.js · error
Unexpected `variable` in weight array for font {}. You only
Error message
Unexpected `variable` in weight array for font {}. You only need `variable`, it includes all available weights. What it means
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.
Source
Thrown at crates/next-core/src/next_font/google/options.rs:117
OneOrManyStrings::One(one) => vec![one],
OneOrManyStrings::Many(many) => many,
})
.unwrap_or_default();
let supports_variable_weight = font_data.weights.iter().any(|el| el == "variable");
let weights = if requested_weights.is_empty() {
if !supports_variable_weight {
anyhow::bail!(
"Missing weight for {}. Available weights: {}",
font_family,
font_data.weights.join(", ")
)
}
FontWeights::Variable
} else if requested_weights.contains("variable") {
if requested_weights.len() > 1 {
anyhow::bail!(
"Unexpected `variable` in weight array for font {}. You only need `variable`, it \
includes all available weights.",
font_family
)
}
FontWeights::Variable
} else {
for requested_weight in &requested_weights {
if !font_data.weights.contains(requested_weight) {
anyhow::bail!(
"Unknown weight {} for font {}.\nAvailable weights: {}",
requested_weight,
font_family,
font_data.weights.join(", ")
)
}
}View on GitHub (pinned to 0ae8c72462)
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.
Example fix
// before
const font = Inter({ subsets: ['latin'], weight: ['variable', '400'] })
// after
const font = Inter({ subsets: ['latin'], weight: 'variable' }) Defensive patterns
Strategy: validation
Prevention
- 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'.
When it happens
Trigger: Passing `weight: ['variable', '400']` (or any combination where requested_weights contains 'variable' and has length > 1) to a variable Google font.
Common situations: Misunderstanding that 'variable' is a catch-all; copy-pasting a weight list and appending 'variable'; typo in a generated config.
Related errors
- Axes can only be defined for variable fonts when the weight
- Missing weight for {}. Available weights: {}
- Unknown weight {} for font {}. Available weights: {}
- Axes can only be defined for variable fonts.
- Only zero or one arguments to font functions are currently s
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/f887347214d8cb53.
Report an issue: GitHub.