{"record":{"id":"40d1f4aad377ef84","repo":"sipeed/picoclaw","slug":"invalid-host-value-w","errorCode":null,"errorMessage":"invalid --host value: %w","messagePattern":"invalid --host value: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/picoclaw/internal/gateway/command.go","lineNumber":23,"sourceCode":"\t\"os\"\n\n\t\"github.com/spf13/cobra\"\n\n\t\"github.com/sipeed/picoclaw/cmd/picoclaw/internal\"\n\t\"github.com/sipeed/picoclaw/pkg/config\"\n\t\"github.com/sipeed/picoclaw/pkg/gateway\"\n\t\"github.com/sipeed/picoclaw/pkg/logger\"\n\t\"github.com/sipeed/picoclaw/pkg/netbind\"\n\t\"github.com/sipeed/picoclaw/pkg/utils\"\n)\n\nfunc resolveGatewayHostOverride(explicit bool, host string) (string, error) {\n\tif !explicit {\n\t\treturn \"\", nil\n\t}\n\tnormalized, err := netbind.NormalizeHostInput(host)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid --host value: %w\", err)\n\t}\n\treturn normalized, nil\n}\n\nfunc NewGatewayCommand() *cobra.Command {\n\tvar debug bool\n\tvar noTruncate bool\n\tvar allowEmpty bool\n\tvar host string\n\n\tcmd := &cobra.Command{\n\t\tUse:     \"gateway\",\n\t\tAliases: []string{\"g\"},\n\t\tShort:   \"Start picoclaw gateway\",\n\t\tArgs:    cobra.NoArgs,\n\t\tPreRunE: func(_ *cobra.Command, _ []string) error {\n\t\t\tif noTruncate && !debug {\n\t\t\t\treturn fmt.Errorf(\"the --no-truncate option can only be used in conjunction with --debug (-d)\")","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/cmd/picoclaw/internal/gateway/command.go#L5-L41","documentation":"When `picoclaw gateway` gets an explicit --host, resolveGatewayHostOverride normalizes it with netbind.NormalizeHostInput, which parses a comma-separated list of host tokens (IP literals, 'localhost', '*') into canonical form. This error wraps a token-parse failure: the value is not a host form netbind accepts. It fires in RunE before the gateway starts.","triggerScenarios":"`picoclaw gateway --host 999.1.1.1` (malformed IPv4), `--host ::zz` (bad IPv6), `--host http://0.0.0.0` (scheme included), `--host 127.0.0.1:8080` (port included), or stray commas/empty tokens in the list.","commonSituations":"Copying a bind address with its port from another tool's config; including a URL scheme; typos; assuming hostnames with paths are accepted.","solutions":["Pass bare hosts only, comma-separated: `--host 127.0.0.1,::1`","Remove any :port - the gateway port is configured separately","Use `--host '*'` or `0.0.0.0` for all interfaces, `localhost` for loopback only","Check `picoclaw gateway --help` for the accepted forms on your build"],"exampleFix":"# before\npicoclaw gateway --host http://0.0.0.0:8080\n# after\npicoclaw gateway --host 0.0.0.0","handlingStrategy":"validation","validationCode":"if _, err := netbind.NormalizeHostInput(host); err != nil {\n    return fmt.Errorf(\"reject --host %q before gateway start: %w\", host, err)\n}","typeGuard":"func isGatewayHostToken(s string) bool {\n    s = strings.TrimSpace(s)\n    if s == \"\" || s == \"*\" || strings.EqualFold(s, \"localhost\") {\n        return s != \"\"\n    }\n    return net.ParseIP(strings.Trim(s, \"[]\")) != nil\n}","tryCatchPattern":"host, err := netbind.NormalizeHostInput(raw)\nif err != nil {\n    // strip scheme/port with a message showing accepted forms; do not start gateway\n    return fmt.Errorf(\"--host accepts IPs, localhost, or '*' (comma-separated): %w\", err)\n}","preventionTips":["Pass bare IPs/'localhost'/'*' to --host; never host:port or URLs","Configure the port via its own setting, not --host","Dry-run normalization with netbind.NormalizeHostInput in launch scripts"],"tags":["gateway","cli","networking","validation"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}