glanceapp/glance · error

parsing URL: %v

Error message

parsing URL: %v

What it means

iframe widget initialization failed because url.Parse rejected the configured source. As with other URL validation errors, url.Parse only fails on control characters or malformed percent-escapes; a missing scheme passes here but produces a broken iframe at render time.

Source

Thrown at internal/glance/widget-iframe.go:27

var iframeWidgetTemplate = mustParseTemplate("iframe.html", "widget-base.html")

type iframeWidget struct {
	widgetBase `yaml:",inline"`
	cachedHTML template.HTML `yaml:"-"`
	Source     string        `yaml:"source"`
	Height     int           `yaml:"height"`
}

func (widget *iframeWidget) initialize() error {
	widget.withTitle("IFrame").withError(nil)

	if widget.Source == "" {
		return errors.New("source is required")
	}

	if _, err := url.Parse(widget.Source); err != nil {
		return fmt.Errorf("parsing URL: %v", err)
	}

	if widget.Height == 50 {
		widget.Height = 300
	} else if widget.Height < 50 {
		widget.Height = 50
	}

	widget.cachedHTML = widget.renderTemplate(widget, iframeWidgetTemplate)

	return nil
}

func (widget *iframeWidget) Render() template.HTML {
	return widget.cachedHTML
}

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Rewrite and quote the source: value
  2. Percent-encode stray % characters (%25)
  3. Include https:// so the iframe actually loads after validation passes

Example fix

# before
- type: iframe
  source: example.com/embed%zz
# after
- type: iframe
  source: "https://example.com/embed"
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(widget.Source)
if err != nil || u.Scheme == "" || u.Host == "" {
    return fmt.Errorf("iframe source %q must be an absolute http(s) URL", widget.Source)
}

Type guard

func isAbsoluteHTTPSource(s string) bool {
    u, err := url.Parse(s)
    return err == nil && (u.Scheme == "http" || u.Scheme == "https") && u.Host != ""
}

Try / catch

if err := widget.initialize(); err != nil {
    widget.withError(err) // show config error in the panel instead of failing the page
}

Prevention

When it happens

Trigger: source: contains control characters, invalid escape sequences like '%zz', or unquoted YAML that gets mangled.

Common situations: Copy-paste artifacts in the source field; URLs with query strings containing raw % characters; YAML special-character issues.

Related errors


AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15). Data as JSON: /api/errors/1cefe1a2532bba2f. Report an issue: GitHub.