{"record":{"id":"961a3389af944b83","repo":"wavetermdev/waveterm","slug":"border-color-v","errorCode":null,"errorMessage":"--border-color: %v","messagePattern":"--border-color: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-setbg.go","lineNumber":101,"sourceCode":"\t\treturn validateHexColor(color)\n\t}\n\tif !CssColorNames[strings.ToLower(color)] {\n\t\treturn fmt.Errorf(\"invalid color %q: must be a hex color (#RRGGBB or #RRGGBBAA) or a CSS color name\", color)\n\t}\n\treturn nil\n}\n\nfunc setBgRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"setbg\", rtnErr == nil)\n\t}()\n\n\tborderColorChanged := cmd.Flags().Changed(\"border-color\")\n\tactiveBorderColorChanged := cmd.Flags().Changed(\"active-border-color\")\n\n\tif borderColorChanged {\n\t\tif err := validateColor(setBgBorderColor); err != nil {\n\t\t\treturn fmt.Errorf(\"--border-color: %v\", err)\n\t\t}\n\t}\n\tif activeBorderColorChanged {\n\t\tif err := validateColor(setBgActiveBorderColor); err != nil {\n\t\t\treturn fmt.Errorf(\"--active-border-color: %v\", err)\n\t\t}\n\t}\n\n\t// Create base metadata\n\tmeta := map[string]interface{}{}\n\n\t// Handle opacity-only change or clear\n\tif len(args) == 0 {\n\t\tif !cmd.Flags().Changed(\"opacity\") && !setBgClear && !borderColorChanged && !activeBorderColorChanged {\n\t\t\tOutputHelpMessage(cmd)\n\t\t\treturn fmt.Errorf(\"setbg requires an image path or color value\")\n\t\t}\n\t\tif setBgOpacity < 0 || setBgOpacity > 1 {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-setbg.go#L83-L119","documentation":"Wrapper around validateColor specifically for the --border-color flag: when the flag was explicitly provided, its value is validated and any failure is re-raised prefixed with \"--border-color: \". The root cause is always one of the color validation errors (missing '#', wrong hex length, bad hex digits, unknown color name).","triggerScenarios":"Any `wsh setbg --border-color <invalid>` invocation where the value is not '#' hex in 6/8-digit form nor a CSS color name.","commonSituations":"Shell eating the '#' (unquoted '#FF0000' becomes empty/commented in some shells); typos; 3-digit hex shorthand.","solutions":["Quote the value and include '#': `wsh setbg --border-color '#00FF00'`.","Use a valid CSS color name: `--border-color green`.","Check the wrapped message after the prefix to see which validation rule failed (format vs digits vs name)."],"exampleFix":"// before\nwsh setbg --border-color 00FF00\n// after\nwsh setbg --border-color '#00FF00'","handlingStrategy":"validation","validationCode":"if bc := flags[\"--border-color\"]; bc != \"\" && !isAcceptableColor(bc) {\n    return fmt.Errorf(\"--border-color %q invalid: use '#RRGGBB', '#RRGGBBAA', or a CSS name\", bc)\n}","typeGuard":"func isAcceptableColor(c string) bool {\n    if strings.HasPrefix(c, \"#\") { return regexp.MustCompile(`^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$`).MatchString(c) }\n    return CssColorNames[strings.ToLower(c)]\n}","tryCatchPattern":"if err := run(); err != nil {\n    var ve *colorFlagError\n    if errors.As(err, &ve) && ve.Flag == \"--border-color\" { /* fix the border-color value and retry */ }\n}","preventionTips":["Quote '#'-prefixed values so the shell doesn't swallow them.","Validate both border-color and active-border-color in scripts before invoking.","Prefer hex values over color names for deterministic behavior."],"tags":["cli","validation","color","flags"],"backgroundTag":"invalid-color-format","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}