{"record":{"id":"e02a3b5e08045b08","repo":"JuliusBrussee/caveman","slug":"kms-invalid-scaleway-region","errorCode":null,"errorMessage":"kms: invalid Scaleway region","messagePattern":"kms: invalid Scaleway region","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/kms/kms.go","lineNumber":338,"sourceCode":"\t\treturn fmt.Errorf(\"kms: generate probe: %w\", err)\n\t}\n\tenvelope, err := c.Encrypt(ctx, plaintext)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"kms: probe encrypt: %w\", err)\n\t}\n\tdecrypted, err := c.Decrypt(ctx, envelope)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"kms: probe decrypt: %w\", err)\n\t}\n\tif !bytes.Equal(decrypted, plaintext) {\n\t\treturn errors.New(\"kms: probe plaintext mismatch\")\n\t}\n\treturn nil\n}\n\nfunc validateLocation(region, keyID string) error {\n\tif !regionPattern.MatchString(region) {\n\t\treturn errors.New(\"kms: invalid Scaleway region\")\n\t}\n\tif !keyIDPattern.MatchString(keyID) {\n\t\treturn errors.New(\"kms: invalid Scaleway key ID\")\n\t}\n\treturn nil\n}\n\nfunc (c *Client) call(ctx context.Context, region, keyID, operation string, input, output any) error {\n\tbody, err := json.Marshal(input)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"kms: encode %s request: %w\", operation, err)\n\t}\n\tendpoint := c.apiBaseURL + \"/key-manager/v1alpha1/regions/\" + url.PathEscape(region) +\n\t\t\"/keys/\" + url.PathEscape(keyID) + \"/\" + operation\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"kms: create %s request: %w\", operation, err)\n\t}","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/kms/kms.go#L320-L356","documentation":"validateLocation checks the region against regionPattern before building KMS API URLs. A region not matching the expected Scaleway region format (e.g. fr-par) produces this error at client construction (New) or decrypt-time URL composition.","triggerScenarios":"Config.Region left empty, set to a wrong identifier (\"paris\", \"eu-west-1\", \"FR-PAR\"), or built from a malformed env var.","commonSituations":"Copy-pasting AWS region names into a Scaleway config, missing REGION env var, typos or uppercase region strings from deployment templates.","solutions":["Use a valid Scaleway region such as fr-par, nl-ams, or pl-waw","Check the REGION/env value with strings.TrimSpace and lowercase before passing to New","Log the region value at startup to catch config plumbing errors early"],"exampleFix":"// before\nregion := strings.ToUpper(os.Getenv(\"REGION\")) // \"FR-PAR\"\n// after\nregion := strings.ToLower(strings.TrimSpace(os.Getenv(\"REGION\"))) // \"fr-par\"","handlingStrategy":"validation","validationCode":"region := strings.ToLower(strings.TrimSpace(cfg.Region))\nif !regexp.MustCompile(`^[a-z]{2}-[a-z]{3}$`).MatchString(region) {\n\treturn fmt.Errorf(\"invalid Scaleway region: %q\", cfg.Region)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use canonical Scaleway regions (fr-par, nl-ams, pl-waw)","Normalize env-derived values (trim, lowercase)","Add startup validation of region/key config before network use"],"tags":["kms","config","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}