{"record":{"id":"c7945982abf87415","repo":"JuliusBrussee/caveman","slug":"cache-replay-anthropic-api-key-unavailable","errorCode":null,"errorMessage":"cache-replay: ANTHROPIC_API_KEY unavailable","messagePattern":"cache-replay: ANTHROPIC_API_KEY unavailable","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cmd/cache-replay/main.go","lineNumber":381,"sourceCode":"\t\treturn nil, \"\", fmt.Errorf(\"cache-replay: trace exceeds %d bytes\", maxBytes)\n\t}\n\treturn records, hex.EncodeToString(hash.Sum(nil)), nil\n}\n\nfunc validateProviderCredentials(records []cachebench.TraceRecord) error {\n\tproviders := map[string]bool{}\n\tfor _, record := range records {\n\t\tproviders[record.Provider] = true\n\t}\n\tfor provider := range providers {\n\t\tswitch provider {\n\t\tcase \"openai\":\n\t\t\tif os.Getenv(\"OPENAI_API_KEY\") == \"\" {\n\t\t\t\treturn errors.New(\"cache-replay: OPENAI_API_KEY unavailable\")\n\t\t\t}\n\t\tcase \"anthropic\":\n\t\t\tif os.Getenv(\"ANTHROPIC_API_KEY\") == \"\" {\n\t\t\t\treturn errors.New(\"cache-replay: ANTHROPIC_API_KEY unavailable\")\n\t\t\t}\n\t\tcase \"gemini\":\n\t\t\tif os.Getenv(\"GEMINI_API_KEY\") == \"\" {\n\t\t\t\treturn errors.New(\"cache-replay: GEMINI_API_KEY unavailable\")\n\t\t\t}\n\t\tcase \"bedrock\":\n\t\t\tif os.Getenv(\"AWS_BEARER_TOKEN_BEDROCK\") == \"\" && (os.Getenv(\"AWS_ACCESS_KEY_ID\") == \"\" || os.Getenv(\"AWS_SECRET_ACCESS_KEY\") == \"\") {\n\t\t\t\treturn errors.New(\"cache-replay: Bedrock bearer token or AWS access credentials unavailable\")\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"cache-replay: unsupported provider %q\", provider)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc verifierEnvironment(extra []string) ([]string, error) {\n\tallowed := map[string]bool{\"PATH\": true, \"LANG\": true, \"LC_ALL\": true, \"TMPDIR\": true}","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cmd/cache-replay/main.go#L363-L399","documentation":"validateProviderCredentials found trace records for the 'anthropic' provider but the ANTHROPIC_API_KEY environment variable is unset/empty. Presence-only check performed before any provider request is sent.","triggerScenarios":"Thrown at cacheengine/cmd/cache-replay/main.go:381 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Export ANTHROPIC_API_KEY in the environment running cache-replay","Remove anthropic records from the trace if Anthropic replay is not intended"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}