{"record":{"id":"280a920c7eeb0599","repo":"gohugoio/hugo","slug":"module-q-not-found","errorCode":null,"errorMessage":"module %q not found","messagePattern":"module %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/collect.go","lineNumber":287,"sourceCode":"\n\tif moduleDir == \"\" {\n\t\tif requestedVersionQuery == \"\" {\n\t\t\tmod = c.gomods.GetByPath(modulePath)\n\t\t\tif mod != nil {\n\t\t\t\tmoduleDir = mod.Dir\n\t\t\t}\n\t\t}\n\n\t\tif moduleDir == \"\" {\n\t\t\tif isProbablyModule(modulePath) {\n\t\t\t\tif requestedVersionQuery != \"\" {\n\t\t\t\t\tvar err error\n\t\t\t\t\tmod, err = c.downloadModuleVersion(modulePath, requestedVersionQuery)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tif mod == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"module %q not found\", modulePath)\n\t\t\t\t\t}\n\t\t\t\t\tmoduleDir = mod.Dir\n\t\t\t\t\tversionMod = mod.Version\n\t\t\t\t} else if c.GoModulesFilename != \"\" {\n\t\t\t\t\t// See https://golang.org/ref/mod#version-queries\n\t\t\t\t\t// This will select the latest release-version (not beta etc.).\n\t\t\t\t\tconst versionQuery = \"upgrade\"\n\t\t\t\t\t// Try to \"go get\" it and reload the module configuration.\n\n\t\t\t\t\t// Note that we cannot use c.Get for this, as that may\n\t\t\t\t\t// trigger a new module collection and potentially create a infinite loop.\n\t\t\t\t\tif err := c.get(fmt.Sprintf(\"%s@%s\", modulePath, versionQuery)); err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\tif err := c.loadModules(); err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/collect.go#L269-L305","documentation":"In getAndCreateModule, after an explicit-version download (downloadModuleVersion) returned no error but a nil module. Hugo requested path@version, the call succeeded without error, yet no module object came back — so it cannot proceed. This is an unusual defensive check rather than a normal user-facing failure.","triggerScenarios":"downloadModuleVersion returns (nil, nil) — theoretically when go mod download reports success but produces a goModule with an empty Dir and no Error, which is not expected from a real toolchain. Reachable only via unusual toolchain behaviour or a future code path that returns nil without error.","commonSituations":"Practically not hit in normal operation; would indicate a toolchain/wrapper returning an empty-but-successful result, or a regression in downloadModuleVersion.","solutions":["Re-run the build (transient), then reproduce with `go mod download -json path@version` and check the JSON has a non-empty Dir.","Upgrade the Go toolchain to a version compatible with your Hugo release.","Report upstream to Hugo if the go command clearly returns a valid module but Hugo still sees nil.","Clear caches: `go clean -modcache && hugo mod clean`."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// Before relying on an explicit-version download, confirm a module comes back\nm, err := c.downloadModuleVersion(path, version)\nif err == nil && m == nil {\n  err = fmt.Errorf(\"module %q returned empty after download\", path)\n}","typeGuard":"null","tryCatchPattern":"// if err == nil && m == nil { /* retry once, then report path as unresolvable */ }","preventionTips":["Pin to versions known to resolve via `go mod download`.","Clear the module cache on suspicious empties.","Upgrade Go/Hugo together to avoid format skew."],"tags":["modules","go-toolchain","hugo-module"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}