{"record":{"id":"0fb30c98bd0bc135","repo":"JuliusBrussee/caveman","slug":"bedrock-missing-credential","errorCode":null,"errorMessage":"bedrock: missing credential","messagePattern":"bedrock: missing credential","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/providers/bedrock/signing.go","lineNumber":203,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"bedrock: exact request payload hash is unavailable\")\n\t}\n\tdefer body.Close()\n\traw, err := io.ReadAll(body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"bedrock: exact request payload hash is unavailable\")\n\t}\n\treturn awssig.HashPayload(raw), nil\n}\n\nfunc credentialAuthKind(credential providers.Credential) (string, error) {\n\tkind := strings.ToLower(strings.TrimSpace(credential.AuthKind))\n\tswitch kind {\n\tcase \"bedrock_api_key\", \"aws_access_keys\":\n\t\treturn kind, nil\n\tcase \"\":\n\t\tkey := strings.TrimSpace(credential.Key)\n\t\tif key == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"bedrock: missing credential\")\n\t\t}\n\t\t// Backward compatibility for existing x-cave-upstream-key and stored\n\t\t// connection values. A complete colon-form credential remains IAM. An\n\t\t// AKIA/ASIA-looking partial value fails as IAM instead of being sent as a\n\t\t// bearer. Every other opaque value is a Bedrock API key.\n\t\tif _, err := parseAWSCredentials(key); err == nil {\n\t\t\treturn \"aws_access_keys\", nil\n\t\t}\n\t\tif strings.HasPrefix(key, \"AKIA\") || strings.HasPrefix(key, \"ASIA\") {\n\t\t\treturn \"aws_access_keys\", nil\n\t\t}\n\t\treturn \"bedrock_api_key\", nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"bedrock: unsupported credential auth kind\")\n\t}\n}\n\n// parseAWSCredentials decodes the \"accessKeyId:secretAccessKey[:sessionToken]\"","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/providers/bedrock/signing.go#L185-L221","documentation":"credentialAuthKind infers the auth kind when credential.AuthKind is empty. With no AuthKind and an empty Key there is nothing to authenticate with, so it errors rather than passing an unsigned/empty credential upstream.","triggerScenarios":"credential.AuthKind is \"\" (or whitespace) and credential.Key is also empty/whitespace when SanitizeAndMapHeaders resolves the Bedrock credential.","commonSituations":"Bedrock provider configured without x-cave-upstream-key set; a stored connection whose secret was deleted or rotated away; env var for the key unset so the credential struct is zero-valued; typo in the header/config key name so the value never lands in Key.","solutions":["Set the credential key: either a Bedrock API key or accessKeyId:secretAccessKey[:sessionToken] in x-cave-upstream-key","Explicitly set AuthKind (\"bedrock_api_key\" or \"aws_access_keys\") along with the Key so inference is not needed","Check the proxy config/env to confirm the credential source is actually populated and the field name matches"],"exampleFix":"// before\n// x-cave-upstream-key not set for bedrock provider\n// after\n// x-cave-upstream-key: AKIA...:wJalr... (IAM) or <bedrock-api-key>","handlingStrategy":"validation","validationCode":"func hasBedrockCredential(cred providers.Credential) bool {\n\treturn strings.TrimSpace(cred.AuthKind) != \"\" || strings.TrimSpace(cred.Key) != \"\"\n}\nif !hasBedrockCredential(cred) { return errors.New(\"bedrock provider requires x-cave-upstream-key\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast at startup if the Bedrock provider is enabled without a key","Verify env var/secret names at config load","Document required credential fields for the provider"],"tags":["bedrock","credentials","config"],"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"}