{"record":{"id":"65608ae8d9e09eda","repo":"hashicorp/terraform","slug":"no-releases-match-the-given-constraints-s","errorCode":null,"errorMessage":"no releases match the given constraints %s","messagePattern":"no releases match the given constraints (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/providers_mirror.go","lineNumber":162,"sourceCode":"\t// - It ignores what's already present and just always downloads everything\n\t//   that the configuration requires. This is a command intended to be run\n\t//   infrequently to update a mirror, so it doesn't need to optimize away\n\t//   fetches of packages that might already be present.\n\n\tfor provider, constraints := range reqs {\n\t\tif provider.IsBuiltIn() {\n\t\t\tc.Ui.Output(fmt.Sprintf(\"- Skipping %s because it is built in to Terraform CLI\", provider.ForDisplay()))\n\t\t\tcontinue\n\t\t}\n\t\tconstraintsStr := getproviders.VersionConstraintsString(constraints)\n\t\tc.Ui.Output(fmt.Sprintf(\"- Mirroring %s...\", provider.ForDisplay()))\n\t\t// First we'll look for the latest version that matches the given\n\t\t// constraint, which we'll then try to mirror for each target platform.\n\t\tacceptable := versions.MeetingConstraints(constraints)\n\t\tavail, _, err := source.AvailableVersions(ctx, provider)\n\t\tcandidates := avail.Filter(acceptable)\n\t\tif err == nil && len(candidates) == 0 {\n\t\t\terr = fmt.Errorf(\"no releases match the given constraints %s\", constraintsStr)\n\t\t}\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\t\ttfdiags.Error,\n\t\t\t\t\"Provider not available\",\n\t\t\t\tfmt.Sprintf(\"Failed to download %s from its origin registry: %s.\", provider.String(), err),\n\t\t\t))\n\t\t\tcontinue\n\t\t}\n\t\tselected := candidates.Newest()\n\t\tif !lockedDeps.Empty() && parsedArgs.LockFile {\n\t\t\tselected = lockedDeps.Provider(provider).Version()\n\t\t\tc.Ui.Output(fmt.Sprintf(\"  - Selected v%s to match dependency lock file\", selected.String()))\n\t\t} else if len(constraintsStr) > 0 {\n\t\t\tc.Ui.Output(fmt.Sprintf(\"  - Selected v%s to meet constraints %s\", selected.String(), constraintsStr))\n\t\t} else {\n\t\t\tc.Ui.Output(fmt.Sprintf(\"  - Selected v%s with no constraints\", selected.String()))\n\t\t}","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/providers_mirror.go#L144-L180","documentation":"During `terraform providers mirror`, for each required provider the command queries source.AvailableVersions and filters by versions.MeetingConstraints(constraints). If the call succeeds but yields zero candidates, this error is set (then wrapped into the 'Provider not available' Sourceless diagnostic). It specifically means the registry had versions but none matched the configured version constraint string.","triggerScenarios":"providers mirror loops over reqs; source.AvailableVersions returns (avail, _, nil); avail.Filter(acceptable) is empty because no published version satisfies the required_providers version constraint (e.g. ~> 5.50 but only 5.0–5.30 published, or >= 2.0 with only 1.x available).","commonSituations":"Over-constrained required_providers (>= X.Y where no such release exists); typo in version; provider moved registries and the new source has different version history; mirroring right after a yank/deprecation of the only matching release.","solutions":["Loosen or correct the version constraint in required_providers to match a published version (check the registry UI or terraform providers mirror -platform ... output).","Confirm the source address is correct (registry.terraform.io/<ns>/<name>) and the registry has the expected versions.","Remove a yanked version from the constraint or pin to a specific known-good release.","Re-run terraform init -upgrade to let the resolver pick the newest compatible version, then mirror."],"exampleFix":"// before: no version matches '~> 9.0'\nrequired_providers { example = { version = \"~> 9.0\" } }\n// after\nrequired_providers { example = { version = \"~> 3.0\" } }","handlingStrategy":"validation","validationCode":"// Check that the registry has a version matching the constraint before mirroring.\navail, _, err := source.AvailableVersions(ctx, provider)\nif err == nil && len(avail.Filter(versions.MeetingConstraints(constraints))) == 0 {\n    return fmt.Errorf(\"no published %s version matches %s; widen the constraint\", provider, constraints)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin to conservative version constraints (~>) rather than exact future versions.","Verify the provider source address and registry before mirroring.","Run terraform init -upgrade to let the resolver pick a valid version first."],"tags":["terraform","provider","mirror","version-constraint","registry"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}