{"record":{"id":"aade986a227f3f3f","repo":"hashicorp/terraform","slug":"registry-response-includes-invalid-protocol-string","errorCode":null,"errorMessage":"registry response includes invalid protocol string %q: %s","messagePattern":"registry response includes invalid protocol string %q: (.+?)","errorType":"validation","errorClass":"ErrQueryFailed","httpStatus":null,"severity":"error","filePath":"internal/getproviders/registry_client.go","lineNumber":395,"sourceCode":"\t\tv, err := ParseVersion(versionStr)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"[WARN] registry response includes invalid version string %q. skipping: %s\", versionStr, err)\n\t\t\tcontinue\n\t\t}\n\t\tversionList = append(versionList, v)\n\t}\n\tversionList.Sort() // lowest precedence first, preserving order when equal precedence\n\n\tprotoVersions := MeetingConstraints(SupportedPluginProtocols)\nFindMatch:\n\t// put the versions in increasing order of precedence\n\tfor index := len(versionList) - 1; index >= 0; index-- { // walk backwards to consider newer versions first\n\t\tfor _, protoStr := range available[versionList[index].String()] {\n\t\t\tp, err := ParseVersion(protoStr)\n\t\t\tif err != nil {\n\t\t\t\treturn UnspecifiedVersion, ErrQueryFailed{\n\t\t\t\t\tProvider: provider,\n\t\t\t\t\tWrapped:  fmt.Errorf(\"registry response includes invalid protocol string %q: %s\", protoStr, err),\n\t\t\t\t}\n\t\t\t}\n\t\t\tif protoVersions.Has(p) {\n\t\t\t\tmatch = versionList[index]\n\t\t\t\tbreak FindMatch\n\t\t\t}\n\t\t}\n\t}\n\treturn match, nil\n}\n\nfunc (c *registryClient) addHeadersToRequest(req *http.Request) {\n\tif c.creds != nil {\n\t\tc.creds.PrepareRequest(req)\n\t}\n\treq.Header.Set(terraformVersionHeader, version.String())\n}\n","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getproviders/registry_client.go#L377-L413","documentation":"In findClosestProtocolCompatibleVersion (the fallback path taken when the requested provider version's protocols are unsupported), the code re-queries the registry's versions and walks each version's protocol strings through ParseVersion. If one fails to parse, it returns ErrQueryFailed wrapping this message. This blocks the helpful 'closest compatible version' suggestion.","triggerScenarios":"Triggered only after an initial ErrProtocolNotSupported, when the secondary ProviderVersions call yields a per-version protocols array containing a non-version string (\"v6\", \"\", \"latest\", \"grpc\").","commonSituations":"Registry emits inconsistent protocol strings between the versions list and the download endpoint; a version list entry with a null/empty protocols value; a private registry bug surfacing only on the version-enumeration endpoint.","solutions":["Inspect the registry's /versions response for the cited provider and fix any malformed protocol strings.","Pin the provider to a version whose protocol Terraform supports directly (>=5,<7) to avoid the fallback path.","Upgrade/patch the registry backend so protocol strings are valid semver."],"exampleFix":"// before (versions endpoint)\n{\"version\":\"1.0\",\"protocols\":[\"latest\"]}\n// after\n{\"version\":\"1.0\",\"protocols\":[\"6.0\"]}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isRegistryProtocolStringErr(err error) bool {\n    var qf getproviders.ErrQueryFailed\n    if errors.As(err, &qf) {\n        return strings.Contains(qf.Wrapped.Error(), \"invalid protocol string\")\n    }\n    return false\n}","tryCatchPattern":"closest, err := client.findClosestProtocolCompatibleVersion(ctx, provider, ver)\nif err != nil {\n    var qf getproviders.ErrQueryFailed\n    if errors.As(err, &qf) && strings.Contains(qf.Wrapped.Error(), \"invalid protocol string\") {\n        // registry versions endpoint has a malformed protocol; skip suggestion\n    }\n    return ver, err\n}","preventionTips":["Pin provider versions whose protocols Terraform supports natively to avoid the fallback path.","Ensure the registry's versions endpoint emits valid semver protocol strings.","Add schema validation to the registry's published version metadata."],"tags":["terraform","registry","protocol-version","semver","fallback"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}