{"record":{"id":"1673245bcd61a741","repo":"glanceapp/glance","slug":"parsing-url-w","errorCode":null,"errorMessage":"parsing URL: %w","messagePattern":"parsing URL: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-docker-containers.go","lineNumber":295,"sourceCode":"\n\treturn hideByDefault\n}\n\n\nfunc fetchDockerContainersFromSource(\n\tsource string,\n\tcategory string,\n\trunningOnly bool,\n\tlabelOverrides map[string]map[string]string,\n) ([]dockerContainerJsonResponse, error) {\n\tvar hostname string\n\n\tvar client *http.Client\n\tif strings.HasPrefix(source, \"tcp://\") || strings.HasPrefix(source, \"http://\") {\n\t\tclient = &http.Client{}\n\t\tparsed, err := url.Parse(source)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"parsing URL: %w\", err)\n\t\t}\n\n\t\tport := parsed.Port()\n\t\tif port == \"\" {\n\t\t\tport = \"80\"\n\t\t}\n\n\t\thostname = parsed.Hostname() + \":\" + port\n\t} else {\n\t\thostname = \"docker\"\n\t\tclient = &http.Client{\n\t\t\tTransport: &http.Transport{\n\t\t\t\tDialContext: func(_ context.Context, _, _ string) (net.Conn, error) {\n\t\t\t\t\treturn net.Dial(\"unix\", source)\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-docker-containers.go#L277-L313","documentation":"url.Parse failed on the widget source when it starts with tcp:// or http://. Practically this only happens for malformed URLs, since Go's parser is lenient (it does not validate scheme-legal characters strictly here). The parsed result is used to build host:port for the Docker API connection.","triggerScenarios":"A docker widget source like 'tcp://host :2375' (space), 'tcp://[bad', or containing control characters; usually the result of a YAML typo or unquoted value that YAML mangles.","commonSituations":"Unquoted YAML scalar being interpreted oddly (e.g. 'tcp://host:2375' is usually fine, but values with colons/spaces need quotes); copy-paste artifacts; template variables producing empty host.","solutions":["Quote the source value in YAML","Check for spaces, brackets, or control characters in the tcp:// URL","Test the URL with a Go snippet or use a known-good value like tcp://host:2375"],"exampleFix":"# before\n  host: tcp://docker host:2375\n# after\n  host: \"tcp://docker-host:2375\"","handlingStrategy":"validation","validationCode":"func validateDockerSource(src string) error {\n    if strings.HasPrefix(src, \"tcp://\") || strings.HasPrefix(src, \"http://\") {\n        u, err := url.Parse(src)\n        if err != nil {\n            return fmt.Errorf(\"bad docker host %q: %w\", src, err)\n        }\n        if u.Hostname() == \"\" {\n            return fmt.Errorf(\"docker host %q missing hostname\", src)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote tcp:// values in YAML","Lint widget configs in CI with a schema that requires scheme://host:port for remote Docker sources"],"tags":["docker","url","yaml","configuration"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}