{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/deploy/google.go#L12-L40","documentation":"`InvalidateGoogleCloudCDN` (in the `withdeploy` build of Hugo) splits the configured `googleCloudCDNOrigin` string on `/` and requires exactly two parts: the GCP project ID and the URL map/origin name, which it passes to `compute.UrlMaps.InvalidateCache`. Any other shape makes the API call impossible, so it fails fast with this error.","triggerScenarios":"Running `hugo deploy` against a target whose `googleCloudCDNOrigin` config value does not contain exactly one `/` — e.g. just the project (`my-project`), an extra segment (`my-project/region/my-urlmap`), or an empty/trailing-slash value.","commonSituations":"Typos in `[deployment.targets]` config, pasting a full resource path (`projects/p/global/urlMaps/m`) instead of the short `<project>/<origin>` form, or confusing this field with the AWS `cloudFrontDistributionID` format.","solutions":["Set `googleCloudCDNOrigin = \"<gcp-project-id>/<url-map-name>\"` in the deployment target config — exactly two slash-separated parts.","Find the URL map name with `gcloud compute url-maps list` and use its short name, not the full resource path.","If you don't use Google Cloud CDN, remove the `googleCloudCDNOrigin` setting or set `invalidateCDN = false`."],"exampleFix":"# before (hugo.toml)\n[[deployment.targets]]\ngoogleCloudCDNOrigin = \"projects/my-proj/global/urlMaps/my-map\"\n# after\n[[deployment.targets]]\ngoogleCloudCDNOrigin = \"my-proj/my-map\"","handlingStrategy":"validation","validationCode":"func validOrigin(o string) bool {\n    parts := strings.Split(o, \"/\")\n    return len(parts) == 2 && parts[0] != \"\" && parts[1] != \"\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write GCS deploy origins as exactly `<project>/<origin>` with a single slash","Validate deployment config with a schema check or a dry-run before real deploys","Keep project IDs in one config constant to avoid hand-typed variants"],"tags":["hugo","hugo-deploy","google-cloud","cdn","configuration"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}