{"record":{"id":"fa587142469d5e67","repo":"JuliusBrussee/caveman","slug":"rewriter-api-key-is-required","errorCode":null,"errorMessage":"rewriter: api key is required","messagePattern":"rewriter: api key is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rewriter/rewriter.go","lineNumber":137,"sourceCode":"\t// on rejected calls so a corpus study can size the rewrites the gate threw\n\t// away. The bytes themselves never leave on a rejection.\n\tCandidateTokens int\n}\n\n// New validates cfg and returns a Client. An unknown provider is an error\n// rather than a default: a silently mis-routed rewriter would produce bytes no\n// gate was designed for.\nfunc New(cfg Config) (*Client, error) {\n\tprovider := strings.ToLower(strings.TrimSpace(cfg.Provider))\n\tif provider != providerAnthropic && provider != providerOpenAI {\n\t\treturn nil, fmt.Errorf(\"rewriter: unsupported provider %q\", cfg.Provider)\n\t}\n\tmodel := strings.TrimSpace(cfg.Model)\n\tif model == \"\" {\n\t\treturn nil, errors.New(\"rewriter: model is required\")\n\t}\n\tif strings.TrimSpace(cfg.APIKey) == \"\" {\n\t\treturn nil, errors.New(\"rewriter: api key is required\")\n\t}\n\ttheta := cfg.Theta\n\tif theta == 0 {\n\t\ttheta = DefaultTheta\n\t}\n\tif theta < 0 {\n\t\treturn nil, fmt.Errorf(\"rewriter: theta must not be negative, got %d\", theta)\n\t}\n\tdoer := cfg.HTTPDoer\n\tif doer == nil {\n\t\tdoer = http.DefaultClient.Do\n\t}\n\treturn &Client{provider: provider, model: model, apiKey: cfg.APIKey, theta: theta, doer: doer}, nil\n}\n\n// Rewrite condenses req.StepBytes, or explains why it did not.\n//\n// Gate 1 (invocation) skips the API call entirely when the step is at or under","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/rewriter/rewriter.go#L119-L155","documentation":"Error \"rewriter: api key is required\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at rewriter/rewriter.go:137 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the rewriter API key."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}