{"record":{"id":"6272cb3f31802dd0","repo":"sipeed/picoclaw","slug":"failed-to-load-config-w-6272cb","errorCode":null,"errorMessage":"failed to load config: %w","messagePattern":"failed to load config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/model/command.go","lineNumber":45,"sourceCode":"  picoclaw model add --help\n\nExamples:\n  picoclaw model                    # Show current default model\n  picoclaw model gpt-5.2           # Set gpt-5.2 as default\n  picoclaw model claude-sonnet-4.6 # Set claude-sonnet-4.6 as default\n  picoclaw model local-model       # Set local VLLM server as default\n  picoclaw model add -b URL -k KEY # Add a model from a custom endpoint\n\nNote: 'local-model' is a special value for using a local VLLM server\n(running at localhost:8000 by default) which does not require an API key.`,\n\t\tArgs: cobra.MaximumNArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tconfigPath := internal.GetConfigPath()\n\n\t\t\t// Load current config\n\t\t\tcfg, err := config.LoadConfig(configPath)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to load config: %w\", err)\n\t\t\t}\n\n\t\t\tif len(args) == 0 {\n\t\t\t\t// Show current default model\n\t\t\t\tshowCurrentModel(cfg)\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// Set new default model\n\t\t\tmodelName := args[0]\n\t\t\treturn setDefaultModel(configPath, cfg, modelName)\n\t\t},\n\t}\n\n\tcmd.AddCommand(newAddCommand())\n\n\treturn cmd\n}","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/model/command.go#L27-L63","documentation":"picoclaw model (any subcommand, including showing the current default) failed while loading the config file via config.LoadConfig on internal.GetConfigPath. The wrapped error is the real cause: YAML/JSON parse errors with line/column, schema validation failures for unknown or ill-typed fields, or read errors such as permission denied.","triggerScenarios":"Config broken by a manual edit (tabs in YAML, wrong types); fields written by a newer picoclaw version failing this version's validation; a truncated config after an interrupted write; an unreadable file.","commonSituations":"Hand-edited configs; version mismatches across machines or after downgrades; config templating in automation; crash-during-save leftovers.","solutions":["Read the wrapped message for the exact line/column or field that failed","Validate the file with a YAML/JSON linter","Fix the field, restore a backup, or move the file aside and regenerate the config","Check file permissions if the error is a read failure"],"exampleFix":"# before (config file; wrong value type)\nagents:\n  defaults:\n    model_name: [custom-prefer]\n\n# after\nagents:\n  defaults:\n    model_name: custom-prefer","handlingStrategy":"validation","validationCode":"configPath := internal.GetConfigPath()\nif _, err := config.LoadConfig(configPath); err != nil {\n  return fmt.Errorf(\"refusing to run with broken config at %s: %w\", configPath, err)\n}","typeGuard":"func isConfigLoadError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"failed to load config\")\n}","tryCatchPattern":"if err := modelCmd.Execute(); err != nil {\n  if isConfigLoadError(err) {\n    // print the wrapped line/column info and offer to open the config\n  }\n  return err\n}","preventionTips":["Validate config edits with a YAML linter before saving","Version-pin picoclaw where configs are shared between machines","Keep backups so a broken config is a restore, not a rebuild"],"tags":["config","cli","yaml","persistence"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}