glanceapp/glance · error
parsing URL: %w
Error message
parsing URL: %w
What it means
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.
Source
Thrown at internal/glance/widget-docker-containers.go:295
return hideByDefault
}
func fetchDockerContainersFromSource(
source string,
category string,
runningOnly bool,
labelOverrides map[string]map[string]string,
) ([]dockerContainerJsonResponse, error) {
var hostname string
var client *http.Client
if strings.HasPrefix(source, "tcp://") || strings.HasPrefix(source, "http://") {
client = &http.Client{}
parsed, err := url.Parse(source)
if err != nil {
return nil, fmt.Errorf("parsing URL: %w", err)
}
port := parsed.Port()
if port == "" {
port = "80"
}
hostname = parsed.Hostname() + ":" + port
} else {
hostname = "docker"
client = &http.Client{
Transport: &http.Transport{
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", source)
},
},
}
}View on GitHub (pinned to 91324e8de7)
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
Example fix
# before host: tcp://docker host:2375 # after host: "tcp://docker-host:2375"
Defensive patterns
Strategy: validation
Validate before calling
func validateDockerSource(src string) error {
if strings.HasPrefix(src, "tcp://") || strings.HasPrefix(src, "http://") {
u, err := url.Parse(src)
if err != nil {
return fmt.Errorf("bad docker host %q: %w", src, err)
}
if u.Hostname() == "" {
return fmt.Errorf("docker host %q missing hostname", src)
}
}
return nil
} Prevention
- Always quote tcp:// values in YAML
- Lint widget configs in CI with a schema that requires scheme://host:port for remote Docker sources
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- %s widget: %v
- recursion depth limit of %d reached
- no pages configured
- user has no name
- assets directory does not exist: %s
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/1673245bcd61a741.
Report an issue: GitHub.