{"record":{"id":"d222037db1e5dc30","repo":"hashicorp/terraform","slug":"not-a-valid-registry-module-source","errorCode":null,"errorMessage":"not a valid registry module source","messagePattern":"not a valid registry module source","errorType":"validation","errorClass":"ErrInvalidModuleSource","httpStatus":null,"severity":"error","filePath":"internal/registry/regsrc/module.go","lineNumber":17,"sourceCode":"// Copyright IBM Corp. 2014, 2026\n// SPDX-License-Identifier: BUSL-1.1\n\npackage regsrc\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"strings\"\n\n\tsvchost \"github.com/hashicorp/terraform-svchost\"\n\t\"github.com/hashicorp/terraform/internal/addrs\"\n)\n\nvar (\n\tErrInvalidModuleSource = errors.New(\"not a valid registry module source\")\n\n\t// nameSubRe is the sub-expression that matches a valid module namespace or\n\t// name. It's strictly a super-set of what GitHub allows for user/org and\n\t// repo names respectively, but more restrictive than our original repo-name\n\t// regex which allowed periods but could cause ambiguity with hostname\n\t// prefixes. It does not anchor the start or end so it can be composed into\n\t// more complex RegExps below. Alphanumeric with - and _ allowed in non\n\t// leading or trailing positions. Max length 64 chars. (GitHub username is\n\t// 38 max.)\n\tnameSubRe = \"[0-9A-Za-z](?:[0-9A-Za-z-_]{0,62}[0-9A-Za-z])?\"\n\n\t// providerSubRe is the sub-expression that matches a valid provider. It\n\t// does not anchor the start or end so it can be composed into more complex\n\t// RegExps below. Only lowercase chars and digits are supported in practice.\n\t// Max length 64 chars.\n\tproviderSubRe = \"[0-9a-z]{1,64}\"\n\n\t// moduleSourceRe is a regular expression that matches the basic","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/registry/regsrc/module.go#L1-L35","documentation":"ErrInvalidModuleSource is returned by regsrc.ParseModuleSource (and related parsers) when a module source string does not match the Terraform Registry format '<namespace>/<name>/<provider>[//<subpath>]'. The grammar is defined by nameSubRe (alphanumeric, max 64 chars, hyphens/underscores only in non-leading/trailing positions) and providerSubRe (lowercase alphanumeric). github.com and bitbucket.org hosts are explicitly disallowed because Terraform special-cases them.","triggerScenarios":"Calling ParseModuleSource / ParseModuleSourceWithHost with a string that has the wrong number of segments, invalid characters, uppercase provider name, or a disallowed host. The regex moduleSourceRe fails to match.","commonSituations":"Typos in the source = line of a module block; using a bare GitHub 'org/repo' shorthand where a fully-qualified registry source is required; mixing up the order of namespace/name/provider; including a host prefix that resolves to github.com/bitbucket.org.","solutions":["Reformat the source as '<host>/<namespace>/<name>/<provider>[//<subpath>]' with a lowercase provider and valid namespace/name characters.","If you meant a Git source, use the git:: prefix or a full git URL instead of a registry shorthand.","For github.com/bitbucket.org sources, use the native VCS source syntax, not the registry parser.","Validate the source string with regsrc.NameRe / ProviderRe before passing it in."],"exampleFix":"// before\nm, err := regsrc.ParseModuleSource(\"Terraform-AWS-modules/vpc/aws\")\n\n// after — lowercase provider, valid namespace\nm, err := regsrc.ParseModuleSource(\"terraform-aws-modules/vpc/aws\")","handlingStrategy":"validation","validationCode":"// Validate before parsing\nif !regsrc.NameRe.MatchString(namespace) || !regsrc.ProviderRe.MatchString(provider) {\n    return fmt.Errorf(\"namespace/provider format invalid\")\n}","typeGuard":"func isValidRegistrySource(s string) bool {\n    // strip optional host prefix, then check moduleSourceRe\n    _, err := regsrc.ParseModuleSource(s)\n    return err == nil\n}","tryCatchPattern":"m, err := regsrc.ParseModuleSource(src)\nif err != nil {\n    // fall back to VCS/git source parsing, or surface a clear error\n    return fmt.Errorf(\"%q is not a valid registry module source (use namespace/name/provider): %w\", src, err)\n}","preventionTips":["Use lowercase provider names and standard namespace/name characters.","Prefer the fully-qualified '<host>/ns/name/provider' form for registry modules.","Use native VCS source syntax (git::, github.com/...) for non-registry modules."],"tags":["registry","module-source","validation","terraform"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}