{"record":{"id":"00a2b55665c30e52","repo":"wavetermdev/waveterm","slug":"parsing-file-path-w","errorCode":null,"errorMessage":"parsing file path: %w","messagePattern":"parsing file path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-file-util.go","lineNumber":107,"sourceCode":"\n\treturn nil\n}\n\nfunc streamReadFromFile(ctx context.Context, fileData wshrpc.FileData, writer io.Writer) error {\n\tbroker := RpcClient.StreamBroker\n\tif broker == nil {\n\t\treturn fmt.Errorf(\"stream broker not available\")\n\t}\n\tif fileData.Info == nil {\n\t\treturn fmt.Errorf(\"file info is required\")\n\t}\n\treaderRouteId := RpcClientRouteId\n\tif readerRouteId == \"\" {\n\t\treturn fmt.Errorf(\"no route id available\")\n\t}\n\tconn, err := connparse.ParseURI(fileData.Info.Path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing file path: %w\", err)\n\t}\n\twriterRouteId := wshutil.MakeConnectionRouteId(conn.Host)\n\treader, streamMeta := broker.CreateStreamReader(readerRouteId, writerRouteId, 256*1024)\n\tdefer reader.Close()\n\tgo func() {\n\t\t<-ctx.Done()\n\t\treader.Close()\n\t}()\n\tdata := wshrpc.CommandFileStreamData{\n\t\tInfo:       fileData.Info,\n\t\tStreamMeta: *streamMeta,\n\t}\n\t_, err = wshclient.FileStreamCommand(RpcClient, data, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"starting file stream: %w\", err)\n\t}\n\t_, err = io.Copy(writer, reader)\n\treturn err","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-file-util.go#L89-L125","documentation":"connparse.ParseURI failed on fileData.Info.Path, and streamReadFromFile wraps it with 'parsing file path:'. The wsh CLI expects paths in its URI scheme (plain paths, or wsh://user@host/... remote paths); anything unparseable fails here.","triggerScenarios":"`wsh file cat` given a malformed URI, e.g. `wsh://` with no host, an unsupported scheme like `ssh://host/file`, or a path with characters that break the URI parser.","commonSituations":"Typo in scheme (ssh:// instead of wsh://), stray characters from shell quoting, passing a Windows drive path or a URL copied from a browser into the command.","solutions":["Print/inspect the exact path passed and correct the URI syntax; use plain local paths or valid wsh://user@host/path form.","Quote the argument in the shell to avoid characters being mangled.","If path came from fixRelativePaths, check its output for corruption (double scheme prefix, empty host)."],"exampleFix":"// before\nwsh file cat ssh://user@host/etc/hosts\n// after\nwsh file cat wsh://user@host/etc/hosts","handlingStrategy":"validation","validationCode":"if _, err := connparse.ParseURI(path); err != nil {\n    return fmt.Errorf(\"invalid wsh path %q: %w\", path, err)\n}\n// path is parseable; proceed to `wsh file cat path`","typeGuard":null,"tryCatchPattern":"if err := runWshFileCat(path); err != nil {\n    var parseErr *parseErr\n    if strings.Contains(err.Error(), \"parsing file path\") {\n        // normalize: strip bad scheme, re-add wsh:// prefix, retry once\n    }\n    return err\n}","preventionTips":["Use plain local paths or well-formed wsh://user@host/path URIs.","Quote paths in the shell to protect special characters.","Sanity-check output of fixRelativePaths for double prefixes or empty hosts."],"tags":["go","wsh","uri","path-parsing"],"backgroundTag":"invalid-uri","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}