{"record":{"id":"7064cdead3eaac2b","repo":"hashicorp/terraform","slug":"subdir-q-not-found","errorCode":null,"errorMessage":"subdir %q not found","messagePattern":"subdir %q not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getmodules/moduleaddrs/subdir.go","lineNumber":89,"sourceCode":"// files on disk in the given directory which we assume contains the content\n// of whichever package this is a subdirectory glob for.\n//\n// Subdir globs are used, for example, when a module registry wants to specify\n// to select the contents of the single directory at the root of a conventional\n// tar archive but it doesn't actually know the exact name of that directory.\n// In that case it might specify a subdir of just \"*\", which this function\n// will then expand into the single subdirectory found inside instDir, or\n// return an error if the result would be ambiguous.\nfunc ExpandSubdirGlobs(instDir string, subDir string) (string, error) {\n\tpattern := filepath.Join(instDir, subDir)\n\n\tmatches, err := filepath.Glob(pattern)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif len(matches) == 0 {\n\t\treturn \"\", fmt.Errorf(\"subdir %q not found\", subDir)\n\t}\n\n\tif len(matches) > 1 {\n\t\treturn \"\", fmt.Errorf(\"subdir %q matches multiple paths\", subDir)\n\t}\n\n\treturn matches[0], nil\n}\n","sourceCodeStart":71,"sourceCodeEnd":98,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/getmodules/moduleaddrs/subdir.go#L71-L98","documentation":"Returned by ExpandSubdirGlobs when filepath.Glob of instDir/subDir yields zero matches. This typically happens for the wildcard '*' subdir used to auto-select a single nested directory: if nothing matches the pattern, the requested subdir does not exist in the extracted package. The %q is the subdir pattern.","triggerScenarios":"A module source specifies '//subdir' (or relies on '*') but the downloaded archive has no entry matching that path — the package layout differs from what the source assumed.","commonSituations":"Module archive reorganized between versions (subdir renamed/removed); wrong tag/ref checked out; tarball published without the expected top-level folder; typo in the subdir component.","solutions":["Inspect the downloaded archive (.terraform/modules/...) to confirm the actual directory layout.","Correct the subdir in the source to match a real path in the package.","Pin a ref/tag known to contain the subdir.","Remove the '//subdir' suffix if the module root is what you need."],"exampleFix":"# before (subdir does not exist in v2)\nsource = \"github.com/org/repo//modules/vpc?ref=v2.0\"\n\n# after (corrected path)\nsource = \"github.com/org/repo//vpc?ref=v2.0\"","handlingStrategy":"validation","validationCode":"// Before ExpandSubdirGlobs, verify the subdir exists in the extracted package.\n// if _, err := os.Stat(filepath.Join(instDir, subDir)); err != nil {\n//     return fmt.Errorf(\"subdir %q not present in package; check archive layout\", subDir)\n// }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the archive layout (tar -tf) before pinning a subdir.","Pin module refs to versions known to contain the subdir.","Remove '//subdir' if the package root is intended."],"tags":["subdir","module-installation","archive"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}