{"record":{"id":"7bf481753ade4b08","repo":"gohugoio/hugo","slug":"origin-must-be-project-origin","errorCode":null,"errorMessage":"origin must be <project>/<origin>","messagePattern":"origin must be <project>/<origin>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deploy/google.go","lineNumber":30,"sourceCode":"// limitations under the License.\n\n//go:build withdeploy\n\npackage deploy\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"google.golang.org/api/compute/v1\"\n)\n\n// Invalidate all of the content in a Google Cloud CDN distribution.\nfunc InvalidateGoogleCloudCDN(ctx context.Context, origin string) error {\n\tparts := strings.Split(origin, \"/\")\n\tif len(parts) != 2 {\n\t\treturn fmt.Errorf(\"origin must be <project>/<origin>\")\n\t}\n\tservice, err := compute.NewService(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\trule := &compute.CacheInvalidationRule{Path: \"/*\"}\n\t_, err = service.UrlMaps.InvalidateCache(parts[0], parts[1], rule).Context(ctx).Do()\n\treturn err\n}\n","sourceCodeStart":12,"sourceCodeEnd":40,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/deploy/google.go#L12-L40","documentation":"InvalidateGoogleCloudCDN (deploy/google.go:28, built only with the 'withdeploy' tag) splits the origin string on '/' and requires exactly two parts: <GCP project>/<CDN origin name>. It then calls compute.UrlMaps.InvalidateCache(project, origin). This fires when GoogleCloudCDNOrigin is missing the slash, has multiple slashes, or is empty-ish.","triggerScenarios":"Setting a target's googleCloudCDNOrigin to 'myproject' (no slash), 'a/b/c' (two slashes), or '/origin' (empty project); the value flows from deployconfig.Target.GoogleCloudCDNOrigin through deploy.go:290.","commonSituations":"Confusing the origin format with a URL or a bare origin name; copy-pasting a CloudFront distribution id into the Google field.","solutions":["Set googleCloudCDNOrigin to exactly '<project>/<origin>', e.g. 'my-gcp-project/my-load-balancer-origin'.","Ensure no leading/trailing slash and exactly one separating slash.","If you do not use Google Cloud CDN, leave googleCloudCDNOrigin empty."],"exampleFix":"# before\n[[deployment.targets]]\nname = \"gcp\"\ngoogleCloudCDNOrigin = \"my-project\"\n\n# after\n[[deployment.targets]]\nname = \"gcp\"\ngoogleCloudCDNOrigin = \"my-project/my-origin\"","handlingStrategy":"validation","validationCode":"// Enforce the <project>/<origin> shape before deploying.\nfunc ValidateGoogleCDNOrigin(origin string) error {\n    parts := strings.Split(origin, \"/\")\n    if len(parts) != 2 || parts[0] == \"\" || parts[1] == \"\" {\n        return fmt.Errorf(\"origin must be <project>/<origin>, got %q\", origin)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := deploy.InvalidateGoogleCloudCDN(ctx, origin); err != nil {\n    return err\n}","preventionTips":["Set googleCloudCDNOrigin to exactly '<project>/<origin>'.","Leave it empty if you don't use Google Cloud CDN.","Validate the value in CI before deploy."],"tags":["deploy","google-cloud","config"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}