{"record":{"id":"61cf1c399efe5d59","repo":"ginuerzh/gost","slug":"errinvalidnode","errorCode":"ErrInvalidNode","errorMessage":"invalid node","messagePattern":"invalid node","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"node.go","lineNumber":15,"sourceCode":"package gost\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n)\n\nvar (\n\t// ErrInvalidNode is an error that implies the node is invalid.\n\tErrInvalidNode = errors.New(\"invalid node\")\n)\n\n// Node is a proxy node, mainly used to construct a proxy chain.\ntype Node struct {\n\tID               int\n\tAddr             string\n\tHost             string\n\tProtocol         string\n\tTransport        string\n\tRemote           string   // remote address, used by tcp/udp port forwarding\n\turl              *url.URL // raw url\n\tUser             *url.Userinfo\n\tValues           url.Values\n\tDialOptions      []DialOption\n\tHandshakeOptions []HandshakeOption\n\tConnectOptions   []ConnectOption\n\tClient           *Client\n\tmarker           *failMarker","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/node.go#L1-L33","documentation":"ErrInvalidNode is the sentinel error returned by ParseNode when the input string, after trimming whitespace, is empty. A proxy Node must at minimum have a non-empty address string; an empty input cannot form a valid node for a proxy chain.","triggerScenarios":"Calling gost.ParseNode(\"\") or ParseNode with a string containing only whitespace (spaces, tabs, newlines); passing an unconfigured config field (e.g. empty peer address) into ParseNode.","commonSituations":"Environment variables or config files with missing/blank proxy URLs; splitting a comma-separated node list that contains empty entries (e.g. \"a:8080,,b:8080\"); template placeholders left unfilled.","solutions":["Trim and skip empty entries before calling ParseNode when parsing node lists.","Provide a valid non-empty node string (scheme://host:port) from config or env.","Validate required address fields at startup and fail fast with a clear message.","Check errors.Is(err, gost.ErrInvalidNode) to distinguish empty input from malformed-URL parse failures."],"exampleFix":"// before\nnode, err := ParseNode(cfg.Proxy) // \"\" -> ErrInvalidNode\n// after\ns := strings.TrimSpace(cfg.Proxy)\nif s == \"\" {\n    return fmt.Errorf(\"proxy address is required\")\n}\nnode, err := ParseNode(s)","handlingStrategy":"validation","validationCode":"s := strings.TrimSpace(input)\nif s == \"\" {\n\treturn fmt.Errorf(\"node address must be a non-empty string\")\n}\nnode, err := gost.ParseNode(s)\nif err != nil {\n\treturn fmt.Errorf(\"parse node %q: %w\", s, err)\n}","typeGuard":"func isValidNodeInput(s string) bool {\n\treturn strings.TrimSpace(s) != \"\"\n}","tryCatchPattern":"node, err := gost.ParseNode(input)\nif err != nil {\n\tif errors.Is(err, gost.ErrInvalidNode) {\n\t\treturn fmt.Errorf(\"empty node input %q\", input)\n\t}\n\treturn err\n}","preventionTips":["Trim and filter empty entries before parsing node lists.","Validate proxy address config at startup and fail fast.","Use errors.Is against ErrInvalidNode to give precise user-facing messages."],"tags":["node","parsing","validation","config"],"backgroundTag":"invalid-node","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}