{"record":{"id":"799a52bdd7e1bb19","repo":"JuliusBrussee/caveman","slug":"kms-auth-token-is-required","errorCode":null,"errorMessage":"kms: auth token is required","messagePattern":"kms: auth token is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/kms/kms.go","lineNumber":94,"sourceCode":"\tprovider := strings.ToLower(strings.TrimSpace(cfg.Provider))\n\tif provider != ProviderScaleway {\n\t\treturn nil, fmt.Errorf(\"kms: unsupported provider %q\", provider)\n\t}\n\tregion, keyID := strings.TrimSpace(cfg.Region), strings.TrimSpace(cfg.KeyID)\n\tif err := validateLocation(region, keyID); err != nil {\n\t\treturn nil, err\n\t}\n\tdecryptKeyIDs := map[string]struct{}{keyID: {}}\n\tfor _, allowedKeyID := range cfg.AllowedDecryptKeyIDs {\n\t\tallowedKeyID = strings.TrimSpace(allowedKeyID)\n\t\tif err := validateLocation(region, allowedKeyID); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdecryptKeyIDs[allowedKeyID] = struct{}{}\n\t}\n\ttoken := strings.TrimSpace(cfg.AuthToken)\n\tif len(token) < 20 {\n\t\treturn nil, errors.New(\"kms: auth token is required\")\n\t}\n\tbaseURL := strings.TrimRight(strings.TrimSpace(cfg.APIBaseURL), \"/\")\n\tif baseURL == \"\" {\n\t\tbaseURL = scalewayAPI\n\t}\n\tparsed, err := url.Parse(baseURL)\n\tif err != nil || parsed.Scheme == \"\" || parsed.Host == \"\" || parsed.User != nil || parsed.RawQuery != \"\" || parsed.Fragment != \"\" {\n\t\treturn nil, errors.New(\"kms: invalid API base URL\")\n\t}\n\tclient := cfg.HTTPClient\n\tif client == nil {\n\t\tclient = &http.Client{\n\t\t\tTimeout: 8 * time.Second,\n\t\t\tCheckRedirect: func(_ *http.Request, _ []*http.Request) error {\n\t\t\t\treturn http.ErrUseLastResponse\n\t\t\t},\n\t\t}\n\t}","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/kms/kms.go#L76-L112","documentation":"New validates the Scaleway KMS client configuration and requires a non-trivial auth token. strings.TrimSpace(cfg.AuthToken) must be at least 20 characters; anything shorter (including empty or whitespace) yields this error before any network activity.","triggerScenarios":"Constructing kms.New with Config.AuthToken empty, unset, whitespace-only, or a placeholder/short value — typically from fromEnvironment when SCALEWAY_SECRET_KEY (or equivalent env var) is missing or truncated.","commonSituations":"Missing KMS auth env var in CI or production, a .env file not loaded, an expired/rotated secret replaced with a truncated string, or copying a key with only part of it pasted.","solutions":["Set the auth token in Config.AuthToken (or the corresponding environment variable) to the full Scaleway secret key","Verify the secret key is complete (Scaleway keys are longer than 20 chars); re-copy from the Scaleway console","Check that your env loading (dotenv, CI secrets) actually populates the variable before kms.New runs"],"exampleFix":"// before\nclient, err := kms.New(ctx, kms.Config{AuthToken: os.Getenv(\"TOKEN\")}) // TOKEN empty\n// after\nif os.Getenv(\"TOKEN\") == \"\" { return errors.New(\"TOKEN not set\") }\nclient, err := kms.New(ctx, kms.Config{AuthToken: os.Getenv(\"TOKEN\")})","handlingStrategy":"validation","validationCode":"token := strings.TrimSpace(os.Getenv(\"SCALEWAY_SECRET_KEY\"))\nif len(token) < 20 {\n\treturn fmt.Errorf(\"SCALEWAY_SECRET_KEY missing or truncated (len=%d)\", len(token))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast at startup with an explicit env-var presence check","Never trim or truncate secret keys when copying them","Load .env / CI secrets before client construction and log which vars are set (not their values)"],"tags":["kms","config","authentication"],"backgroundTag":"missing-credentials","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"}