{"record":{"id":"55d682d9ad403614","repo":"gohugoio/hugo","slug":"unknown-dimension-q","errorCode":null,"errorMessage":"unknown dimension %q","messagePattern":"unknown dimension %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hugolib/sitesmatrix/dimensions.go","lineNumber":285,"sourceCode":"\tif vs == nil {\n\t\treturn nil\n\t}\n\treturn weightedVectorStore{VectorStore: vs, weight: weight}\n}\n\n// Dimension is a dimension in the Hugo build matrix.\ntype Dimension int8\n\nfunc ParseDimension(s string) (int, error) {\n\tswitch s {\n\tcase \"language\":\n\t\treturn Language, nil\n\tcase \"version\":\n\t\treturn Version, nil\n\tcase \"role\":\n\t\treturn Role, nil\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"unknown dimension %q\", s)\n\t}\n}\n\nfunc DimensionName(d int) string {\n\tswitch d {\n\tcase Language:\n\t\treturn \"language\"\n\tcase Version:\n\t\treturn \"version\"\n\tcase Role:\n\t\treturn \"role\"\n\tdefault:\n\t\tpanic(\"unknown dimension\")\n\t}\n}\n\n// Common information provided by all of language, version and role.\ntype DimensionInfo interface {","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/sitesmatrix/dimensions.go#L267-L303","documentation":"ParseDimension converts a string dimension name into its integer constant; only \"language\", \"version\", and \"role\" are valid (sitesmatrix.Language/Version/Role). Any other string reaches the default branch and returns this error. This is an internal API used when configuring the build matrix dimensions from string config or query input.","triggerScenarios":"Calling sitesmatrix.ParseDimension with a typo'd or unsupported name such as \"languages\", \"lang\", \"outputFormat\", or \"kind\". Typically arises from malformed config deserialization or a code path passing a user string directly.","commonSituations":"Custom code or a config key that names a dimension with the wrong token; a Hugo upgrade that renamed/added a dimension while consuming code kept the old name; integration tests feeding arbitrary strings.","solutions":["Correct the dimension string to one of: language, version, role.","If accepting user/config input, validate against this allowlist before calling ParseDimension.","Use DimensionName/Dimension constants instead of raw strings where possible to avoid typos."],"exampleFix":"// before\nd, err := sitesmatrix.ParseDimension(\"languages\") // typo/unknown\n\n// after\nd, err := sitesmatrix.ParseDimension(\"language\")","handlingStrategy":"validation","validationCode":"var validDimensions = map[string]bool{\"language\": true, \"version\": true, \"role\": true}\n\nfunc safeParseDimension(s string) (int, error) {\n    if !validDimensions[s] {\n        return 0, fmt.Errorf(\"unknown dimension %q (want language|version|role)\", s)\n    }\n    return sitesmatrix.ParseDimension(s)\n}","typeGuard":"func isValidDimension(s string) bool {\n    switch s {\n    case \"language\", \"version\", \"role\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use the Dimension constants instead of string literals where possible.","Validate user/config-supplied dimension names against the allowlist before parsing.","Document the three valid dimension names near any config schema that accepts them."],"tags":["sitesmatrix","dimension","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}