{"record":{"id":"0919cc1972392b7a","repo":"hashicorp/terraform","slug":"invalid-url-v-must-be-v","errorCode":null,"errorMessage":"Invalid URL: %v must be: %v","messagePattern":"Invalid URL: (.+?) must be: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/cos/backend.go","lineNumber":309,"sourceCode":"\t\tu, err = url.Parse(fmt.Sprintf(\"https://%s.cos.%s.myqcloud.com\", b.bucket, b.region))\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif v, ok := data.GetOk(\"domain\"); ok {\n\t\tb.domain = v.(string)\n\t\tlog.Printf(\"[DEBUG] Backend: set domain for TencentCloud API client. Domain: [%s]\", b.domain)\n\t}\n\t// set url as endpoint when provided\n\t// \"http://{Bucket}.cos-internal.{Region}.tencentcos.cn\"\n\tif v, ok := data.GetOk(\"endpoint\"); ok {\n\t\tendpoint := v.(string)\n\n\t\tre := regexp.MustCompile(`^(http(s)?)://cos-internal\\.([^.]+)\\.tencentcos\\.cn$`)\n\t\tmatches := re.FindStringSubmatch(endpoint)\n\t\tif len(matches) != 4 {\n\t\t\treturn fmt.Errorf(\"Invalid URL: %v must be: %v\", endpoint, \"http(s)://cos-internal.{Region}.tencentcos.cn\")\n\t\t}\n\n\t\tprotocol := matches[1]\n\t\tregion := matches[3]\n\n\t\t// URL after converting\n\t\tnewUrl := fmt.Sprintf(\"%s://%s.cos-internal.%s.tencentcos.cn\", protocol, b.bucket, region)\n\t\tu, err = url.Parse(newUrl)\n\t\tlog.Printf(\"[DEBUG] Backend: set COS URL as: [%s]\", newUrl)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar getProviderConfig = func(key string) string {\n\t\tvar str string\n\t\tvalue, err := getConfigFromProfile(data, key)\n\t\tif err == nil && value != nil {","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/cos/backend.go#L291-L327","documentation":"Raised in Backend.configure() (cos/backend.go:309) when the `endpoint` attribute is set but does not match the strict regex ^(http(s)?)://cos-internal\\.([^.]+)\\.tencentcos\\.cn$. The endpoint option only accepts the COS internal-access form; any other URL shape is rejected.","triggerScenarios":"Configuring endpoint = \"https://cos.ap-guangzhou.myqcloud.com\" or any string that does not exactly match http(s)://cos-internal.<region>.tencentcos.cn; the regex match returns fewer than 4 groups.","commonSituations":"Trying to use the public COS endpoint via the endpoint option (not supported - endpoint is internal-only); typos in the domain; wrong region segment; missing protocol.","solutions":["Use the exact form endpoint = \"https://cos-internal.ap-guangzhou.tencentcos.cn\" with a real region.","If you want the public endpoint, omit the endpoint attribute entirely; the backend builds the public URL from region/bucket.","Verify the region segment matches a valid TencentCloud region."],"exampleFix":"// before\nterraform {\n  backend \"cos\" {\n    region   = \"ap-guangzhou\"\n    bucket   = \"my-bucket\"\n    endpoint = \"https://cos.ap-guangzhou.myqcloud.com\"\n  }\n}\n// after\nterraform {\n  backend \"cos\" {\n    region   = \"ap-guangzhou\"\n    bucket   = \"my-bucket\"\n    endpoint = \"https://cos-internal.ap-guangzhou.tencentcos.cn\"\n  }\n}","handlingStrategy":"validation","validationCode":"// Validate the cos endpoint matches the internal-access form\nvar endpointRe = regexp.MustCompile(`^(http(s)?)://cos-internal\\.([^.]+)\\.tencentcos\\.cn$`)\nfunc validEndpoint(ep string) error {\n    if len(endpointRe.FindStringSubmatch(ep)) != 4 {\n        return fmt.Errorf(\"Invalid URL: %v must be: %v\", ep, \"http(s)://cos-internal.{Region}.tencentcos.cn\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set endpoint for COS internal access, in the exact required form.","Omit endpoint to use the default public COS URL built from region/bucket.","Keep the region segment in the endpoint consistent with the configured region."],"tags":["cos","tencentcloud","validation","config","endpoint","url","regex"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}