{"record":{"id":"30636c1af8f3bc68","repo":"charmbracelet/crush","slug":"invalid-host-url-v","errorCode":null,"errorMessage":"invalid host URL: %v","messagePattern":"invalid host URL: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/root.go","lineNumber":391,"sourceCode":"\n\tif protoWs.Config.IsConfigured() {\n\t\tif err := clientWs.InitCoderAgent(cmd.Context()); err != nil {\n\t\t\tslog.Error(\"Failed to initialize coder agent\", \"error\", err)\n\t\t}\n\t}\n\n\t// Clean up via Shutdown rather than connectToServer's closure: it stops\n\t// the subscription's reconnect/recovery loop first, so our own exit\n\t// cannot be mistaken for a lost workspace and re-created mid-quit.\n\treturn clientWs, clientWs.Shutdown, nil\n}\n\n// connectToServer ensures the server is running, creates a client and\n// workspace, and returns a cleanup function that deletes the workspace.\nfunc connectToServer(cmd *cobra.Command) (*client.Client, *proto.Workspace, func(), error) {\n\thostURL, err := server.ParseHostURL(clientHost)\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"invalid host URL: %v\", err)\n\t}\n\n\tif err := ensureServer(cmd, hostURL); err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\tdebug, _ := cmd.Flags().GetBool(\"debug\")\n\tyolo, _ := cmd.Flags().GetBool(\"yolo\")\n\tchannels, _ := cmd.Flags().GetStringSlice(\"channels\")\n\tdataDir, _ := cmd.Flags().GetString(\"data-dir\")\n\n\tcwd, err := ResolveCwd(cmd)\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\tc, err := client.NewClient(cwd, hostURL.Scheme, hostURL.Host)\n\tif err != nil {","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/cmd/root.go#L373-L409","documentation":"connectToServer in internal/cmd/root.go parses the --host flag via server.ParseHostURL before connecting to a running crush server. An unparseable host URL (missing scheme, invalid characters, malformed unix socket path) returns 'invalid host URL: %v', preventing any client/server connection.","triggerScenarios":"Passing `--host` with a malformed value: e.g. `--host localhost:8080` without scheme, `--host 'http://:port'`, or an invalid unix:// path; CRUSH_HOST / clientHost set to a bad value in the environment.","commonSituations":"Copy-pasting a host string without `http://` or `unix://` prefix; quoting issues in shell causing stray characters; typo like `htp://`; IPv6 literal without brackets.","solutions":["Prefix the host with a scheme: `--host http://localhost:8080` or `--host unix:///path/to/socket`","Check the CRUSH_HOST/clientHost env var for typos or stray whitespace/quotes","For IPv6 use bracketed form: http://[::1]:8080","Omit --host entirely to use the default local socket"],"exampleFix":"// before\ncrush --host localhost:3117\n// after\ncrush --host http://localhost:3117","handlingStrategy":"validation","validationCode":"u, err := url.Parse(host)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\" && u.Scheme != \"unix\") {\n    return fmt.Errorf(\"host must be http(s):// or unix://, got %q\", host)\n}","typeGuard":null,"tryCatchPattern":"hostURL, err := server.ParseHostURL(clientHost)\nif err != nil {\n    return fmt.Errorf(\"invalid host URL %q: %w\", clientHost, err)\n}","preventionTips":["Always include the scheme (http:// or unix://) in --host","Quote the host value in shells to avoid stray characters","Use bracketed IPv6 literals: http://[::1]:8080"],"tags":["cli","config","url-parsing","server"],"backgroundTag":"invalid-host-url","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}