JuliusBrussee/caveman · error
rewriter: unsupported provider
Error message
rewriter: unsupported provider %q
What it means
rewriter.New validates the Config.Provider field and only accepts the known providers (anthropic, openai, compared case-insensitively after trimming whitespace). Any other value returns this error rather than defaulting, because a silently mis-routed rewriter would produce bytes no gate was designed for.
Solutions
- Set cfg.Provider to exactly "anthropic" or "openai" (case/whitespace are normalized, so "OpenAI " is fine)
- Validate the config value at load time against the same allowed set before constructing the client
- Check where the value originates (env var, flag, config file) for typos or stale values
- Add your provider support upstream if you genuinely need another vendor — the client only implements these two
Example fix
// before
client, err := rewriter.New(rewriter.Config{Provider: cfg.LLMVendor}) // "bedrock"
// after
provider := strings.ToLower(strings.TrimSpace(cfg.LLMVendor))
if provider != "anthropic" && provider != "openai" {
provider = "openai" // or fail fast with a clear config error
}
client, err := rewriter.New(rewriter.Config{Provider: provider}) Defensive patterns
Strategy: validation
Validate before calling
func validProvider(p string) bool {
switch strings.ToLower(strings.TrimSpace(p)) {
case "anthropic", "openai":
return true
}
return false
}
if !validProvider(cfg.Provider) { return nil, fmt.Errorf("provider %q not in {anthropic, openai}", cfg.Provider) } Try / catch
client, err := rewriter.New(cfg)
if err != nil {
if strings.Contains(err.Error(), "unsupported provider") {
return fmt.Errorf("config: provider must be anthropic or openai, got %q", cfg.Provider)
}
return err
} Prevention
- Use a typed enum/constant for provider instead of a free string
- Validate provider at config-load time, not at client construction
- Keep provider names in one place to avoid drift between config and code
- Trim/case-normalize at the config boundary (New does this too)
When it happens
Trigger: Calling rewriter.New(Config{Provider: ...}) with a provider string that is not "anthropic" or "openai" (after ToLower+TrimSpace) — e.g. "azure", "openai-chat", an empty string, or a typo like "anthropicc".
Common situations: Config wired from YAML/env where the provider name comes from a free-form field; renaming providers in an internal config without updating the rewriter config; passing a provider constant from another library; typos in test fixtures (newTestClient exercises this).
Related errors
- CAVEMAN_CCR_MAX_BYTES must be a positive integer
- ccr max storage bytes must be positive
- compat upstream name
- githubapp: app id is required
- kms: unsupported provider
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/a75d4bc962581bba.
Report an issue: GitHub.
Appendix: source
Thrown at rewriter/rewriter.go:130
type Result struct {
Rewritten []byte // includes trailing recovery-pointer line; empty when !Accepted
Accepted bool
RejectReason string // non-empty when !Accepted; e.g. "below_theta", "gate_failure_tokens", "api_error"
InputTokens int // rewriter's own metered usage, for cost netting
OutputTokens int
// CandidateTokens is the inferred size of what the model produced, reported
// on rejected calls so a corpus study can size the rewrites the gate threw
// away. The bytes themselves never leave on a rejection.
CandidateTokens int
}
// New validates cfg and returns a Client. An unknown provider is an error
// rather than a default: a silently mis-routed rewriter would produce bytes no
// gate was designed for.
func New(cfg Config) (*Client, error) {
provider := strings.ToLower(strings.TrimSpace(cfg.Provider))
if provider != providerAnthropic && provider != providerOpenAI {
return nil, fmt.Errorf("rewriter: unsupported provider %q", cfg.Provider)
}
model := strings.TrimSpace(cfg.Model)
if model == "" {
return nil, errors.New("rewriter: model is required")
}
if strings.TrimSpace(cfg.APIKey) == "" {
return nil, errors.New("rewriter: api key is required")
}
theta := cfg.Theta
if theta == 0 {
theta = DefaultTheta
}
if theta < 0 {
return nil, fmt.Errorf("rewriter: theta must not be negative, got %d", theta)
}
doer := cfg.HTTPDoer
if doer == nil {
doer = http.DefaultClient.DoView on GitHub (pinned to 3ee70a1026)