{"record":{"id":"3ba584dcb12558a7","repo":"wavetermdev/waveterm","slug":"error-parsing-source-connection-w","errorCode":null,"errorMessage":"error parsing source connection: %w","messagePattern":"error parsing source connection: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/remote/fileshare/wshfs/wshfs.go","lineNumber":224,"sourceCode":"\nfunc Mkdir(ctx context.Context, path string) error {\n\tlog.Printf(\"Mkdir: %v\", path)\n\tconn, err := parseConnection(ctx, path)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn wshclient.RemoteMkdirCommand(RpcClient, conn.Path, &wshrpc.RpcOpts{Route: wshutil.MakeConnectionRouteId(conn.Host)})\n}\n\nfunc Move(ctx context.Context, data wshrpc.CommandFileCopyData) error {\n\topts := data.Opts\n\tif opts == nil {\n\t\topts = &wshrpc.FileCopyOpts{}\n\t}\n\tlog.Printf(\"Move: srcuri: %v, desturi: %v, opts: %v\", data.SrcUri, data.DestUri, opts)\n\tsrcConn, err := parseConnection(ctx, data.SrcUri)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing source connection: %w\", err)\n\t}\n\tdestConn, err := parseConnection(ctx, data.DestUri)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing destination connection: %w\", err)\n\t}\n\tif srcConn.Host != destConn.Host {\n\t\tisDir, err := copyInternal(srcConn, destConn, opts)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot copy %q to %q: %w\", data.SrcUri, data.DestUri, err)\n\t\t}\n\t\treturn delete_(srcConn, opts.Recursive && isDir)\n\t}\n\treturn moveInternal(srcConn, destConn, opts)\n}\n\nfunc Copy(ctx context.Context, data wshrpc.CommandFileCopyData) error {\n\topts := data.Opts\n\tif opts == nil {","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/remote/fileshare/wshfs/wshfs.go#L206-L242","documentation":"Move parses both the source and destination URIs via parseConnection; when the source URI fails to parse, the error is wrapped as \"error parsing source connection\". Move requires well-formed connection URIs to determine hosts (a cross-host Move degrades to copy+delete), so an invalid SrcUri aborts the operation before any file action occurs.","triggerScenarios":"Calling wshfs.Move (via FileMoveCommand) with CommandFileCopyData.SrcUri that connparse cannot parse — empty string, malformed scheme, invalid characters — while DestUri may be valid.","commonSituations":"Source path built from user input or config with a missing/typo'd \"wsh://\" scheme; empty SrcUri from an unset variable; dragging/pasting a plain Windows-style or relative path where a connection URI is expected.","solutions":["Inspect the wrapped underlying error to see the parse failure reason for SrcUri","Validate/normalize SrcUri is a well-formed connection URI before calling Move","Fix the config/variable supplying SrcUri (empty values are a common cause)","If the source is local, use the proper local path/URI form accepted by connparse"],"exampleFix":"// before\nwshfs.Move(ctx, wshrpc.CommandFileCopyData{SrcUri: \"\", DestUri: \"wsh://host/tmp/b.txt\"})\n// after\nsrc := \"wsh://host/tmp/a.txt\"\nif src == \"\" {\n    return errors.New(\"source uri is empty\")\n}\nwshfs.Move(ctx, wshrpc.CommandFileCopyData{SrcUri: src, DestUri: \"wsh://host/tmp/b.txt\"})","handlingStrategy":"validation","validationCode":"if data.SrcUri == \"\" {\n    return errors.New(\"source uri is required for wshfs.Move\")\n}\nif !strings.Contains(data.SrcUri, \"://\") && !filepath.IsAbs(data.SrcUri) {\n    return fmt.Errorf(\"source uri %q is not a valid connection uri\", data.SrcUri)\n}","typeGuard":"func validSrcUri(d wshrpc.CommandFileCopyData) bool {\n    u, err := url.Parse(d.SrcUri)\n    return d.SrcUri != \"\" && err == nil && (u.Scheme != \"\" || filepath.IsAbs(d.SrcUri))\n}","tryCatchPattern":"err := wshfs.Move(ctx, data)\nif err != nil {\n    if strings.Contains(err.Error(), \"error parsing source connection\") {\n        return fmt.Errorf(\"bad source uri %q: %w\", data.SrcUri, err)\n    }\n    return err\n}","preventionTips":["Validate both SrcUri and DestUri before calling Move","Source config from env/flags through a URI-normalizing helper","Reject empty strings early — they are the most common cause","Test move operations with local and remote URI forms"],"tags":["go","uri-parsing","connection"],"backgroundTag":"invalid-connection-uri","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}