{"record":{"id":"f95c14333aae711b","repo":"charmbracelet/crush","slug":"failed-to-get-follow-flag-v","errorCode":null,"errorMessage":"failed to get follow flag: %v","messagePattern":"failed to get follow flag: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/cmd/logs.go","lineNumber":40,"sourceCode":"\nvar logsCmd = &cobra.Command{\n\tUse:   \"logs\",\n\tShort: \"View crush logs\",\n\tLong:  `View the logs generated by Crush. This command allows you to see the log output for debugging and monitoring.`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tcwd, err := cmd.Flags().GetString(\"cwd\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get current working directory: %v\", err)\n\t\t}\n\n\t\tdataDir, err := cmd.Flags().GetString(\"data-dir\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get data directory: %v\", err)\n\t\t}\n\n\t\tfollow, err := cmd.Flags().GetBool(\"follow\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get follow flag: %v\", err)\n\t\t}\n\n\t\ttailLines, err := cmd.Flags().GetInt(\"tail\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get tail flag: %v\", err)\n\t\t}\n\n\t\tlog.SetLevel(log.DebugLevel)\n\t\tlog.SetOutput(os.Stdout)\n\t\tif !term.IsTerminal(os.Stdout.Fd()) {\n\t\t\tlog.SetColorProfile(colorprofile.NoTTY)\n\t\t}\n\n\t\tcfg, err := config.Load(cwd, dataDir, false)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to load configuration: %v\", err)\n\t\t}\n\t\tlogsFile := filepath.Join(cfg.Config().Options.DataDirectory, \"logs\", \"crush.log\")","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/logs.go#L22-L58","documentation":"The `crush logs` command reads the boolean --follow flag via cmd.Flags().GetBool and wraps any lookup failure with this message. As with the other flag lookups, failure means the flag was never registered on the command — the value itself is always parseable for a bool flag.","triggerScenarios":"RunE querying \"follow\" when the --follow flag registration is absent (fork/custom build), or RunE invoked programmatically without flag setup.","commonSituations":"Rebuilt/patched binaries with dropped flag registration; test harnesses constructing the command manually; refactor that renamed the flag but not the lookup key.","solutions":["Use an official crush build or rebuild from source.","If developing: ensure `cmd.Flags().Bool(\"follow\", false, \"Follow log output\")` is registered.","In tests, register all queried flags before invoking RunE."],"exampleFix":"// before\ncmd.Flags().Bool(\"tail\", true, \"Number of lines to tail\") // follow never registered\n// after\ncmd.Flags().Bool(\"follow\", false, \"Follow log output\")","handlingStrategy":"fallback","validationCode":"if f := cmd.Flags().Lookup(\"follow\"); f == nil {\n    follow = false // default without -f\n}","typeGuard":null,"tryCatchPattern":"follow, err := cmd.Flags().GetBool(\"follow\")\nif err != nil {\n    follow = false\n}","preventionTips":["Keep flag registration and lookup keys in sync (rename both together).","Cover each command with an integration test exercising all flags.","Review fork/patch diffs for dropped cobra flag lines.","Use a helper to register and return flags atomically."],"tags":["cli","cobra","flags"],"backgroundTag":"missing-flag-registration","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}