{"record":{"id":"572556228a144d98","repo":"charmbracelet/crush","slug":"failed-to-override-models-w","errorCode":null,"errorMessage":"failed to override models: %w","messagePattern":"failed to override models: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/app/app.go","lineNumber":280,"sourceCode":"\t}\n}\n\n// RunNonInteractive runs the application in non-interactive mode with the\n// given prompt, printing to stdout.\nfunc (app *App) RunNonInteractive(ctx context.Context, output io.Writer, prompt, largeModel, smallModel string, hideSpinner bool, continueSessionID string, useLast bool) error {\n\tslog.Info(\"Running in non-interactive mode\")\n\n\t// Re-initialize the coder agent without interactive-only tools.\n\tif err := app.InitCoderAgentNonInteractive(ctx); err != nil {\n\t\treturn fmt.Errorf(\"failed to reinitialize agent for non-interactive mode: %w\", err)\n\t}\n\n\tctx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\n\tif largeModel != \"\" || smallModel != \"\" {\n\t\tif err := app.overrideModelsForNonInteractive(ctx, largeModel, smallModel); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to override models: %w\", err)\n\t\t}\n\t}\n\n\tvar (\n\t\tspinner   *format.Spinner\n\t\tstderrTTY bool\n\t\tprogress  bool\n\t)\n\n\tstderrTTY = term.IsTerminal(os.Stderr.Fd())\n\tprogress = app.config.Config().Options.Progress == nil || *app.config.Config().Options.Progress\n\n\tif !hideSpinner && stderrTTY {\n\t\tt := styles.ThemeForProvider(app.config.Config().Models[config.SelectedModelTypeLarge].Provider)\n\n\t\tspinner = format.NewSpinner(ctx, cancel, anim.Settings{\n\t\t\tSize:        10,\n\t\t\tLabel:       \"Generating\",","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/app/app.go#L262-L298","documentation":"When largeModel or smallModel CLI flags are non-empty, RunNonInteractive calls overrideModelsForNonInteractive to override the configured preferred models; any failure there is wrapped with this message. It means the requested model override could not be resolved against known providers (unknown provider/model id or provider data unavailable).","triggerScenarios":"Calling RunNonInteractive with non-empty largeModel/smallModel (e.g. `--model provider/model`) where the provider is not configured, the model id does not exist in the provider catalog, or the provider catalog fetch failed.","commonSituations":"Typo in `--model anthropic/claude-sonnet-4-5` style ids; using a provider that was never configured with credentials; stale/cached provider catalog after a model was renamed or removed upstream.","solutions":["Verify the provider/model id exists: run `crush models` and copy an exact id","Configure credentials for the provider being overridden (e.g. ANTHROPIC_API_KEY)","Drop the --model flag to fall back to configured defaults","Refresh the provider catalog (clear cache / update crush) if the model was renamed"],"exampleFix":"// before\ncrush run \"fix tests\" --model anthropic/claude-3-7-sonnet-latest\n// after\ncrush run \"fix tests\" --model anthropic/claude-sonnet-4-5 // exact id from `crush models`","handlingStrategy":"validation","validationCode":"models := config.Providers() // or `crush models`\nfor _, m := range []string{largeModel, smallModel} {\n\tif m != \"\" && !containsID(models, m) {\n\t\treturn fmt.Errorf(\"unknown model id: %s\", m)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := app.RunNonInteractive(ctx, w, prompt, large, small, true, \"\", false); err != nil {\n\tif strings.Contains(err.Error(), \"failed to override models\") {\n\t\t// fall back to configured defaults\n\t\treturn app.RunNonInteractive(ctx, w, prompt, \"\", \"\", true, \"\", false)\n\t}\n\treturn err\n}","preventionTips":["Copy model ids verbatim from `crush models` output","Ensure provider credentials exist before overriding models","Pin model ids in scripts to versions listed in your provider config"],"tags":["go","model-override","cli","configuration"],"backgroundTag":"unknown-model-id","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}