kataras/iris · warning

name: %s: error: %w

Error message

name: %s: error: %w

What it means

In the embedded file server's DirList renderer, the handler parses the incoming request URI with url.Parse to build listing links (#1882 fix). If the raw RequestURI is malformed and cannot be parsed, listing of that directory entry fails and this wrapped error is returned, naming the entry being processed.

Source

Thrown at core/router/fs.go:591

		return err
	}

	// link to parent directory
	_, err = ctx.WriteString("<li><span style=\"width: 150px; float: left; display: inline-block;\">drwxrwxrwx</span><a href=\"./\">../</a><li>")
	if err != nil {
		return err
	}

	for _, d := range dirs {
		if !dirOptions.ShowHidden && IsHidden(d) {
			continue
		}

		name := toBaseName(d.Name())

		u, err := url.Parse(ctx.Request().RequestURI) // clone url and remove query (#1882).
		if err != nil {
			return fmt.Errorf("name: %s: error: %w", name, err)
		}
		u.RawQuery = ""

		upath := url.URL{Path: path.Join(u.String(), name)}

		downloadAttr := ""
		if dirOptions.Attachments.Enable && !d.IsDir() {
			downloadAttr = " download" // fixes chrome Resource interpreted, other browsers will just ignore this <a> attribute.
		}

		viewName := name
		if d.IsDir() {
			viewName += "/"
		}

		// name may contain '?' or '#', which must be escaped to remain
		// part of the URL path, and not indicate the start of a query
		// string or fragment.

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Inspect the wrapped cause: it is an url.Parse error — fix the request URI that triggered it
  2. Normalize/sanitize request URIs in middleware before they reach the file server
  3. Ensure clients use properly URL-encoded paths (e.g. %20 not raw spaces)
  4. If serving behind a proxy, enable URI normalization on the proxy

Example fix

// middleware before serving
func sanitizeURI(ctx iris.Context) {
    if _, err := url.ParseRequestURI(ctx.Request().RequestURI); err != nil {
        ctx.StatusCode(iris.StatusBadRequest)
        return
    }
    ctx.Next()
}
Defensive patterns

Strategy: validation

Validate before calling

func validURI(raw string) bool {
    _, err := url.ParseRequestURI(raw)
    return err == nil
}

Try / catch

err := fileServer(ctx)
if err != nil && strings.Contains(err.Error(), "url parse") {
    ctx.StatusCode(iris.StatusBadRequest)
    return
}

Prevention

When it happens

Trigger: Serving a directory listing (fs.DirList / Party.DirOptions with ShowList enabled) while a client sends a request whose RequestURI is not a valid URL (bad percent-encodings like %zz, illegal control characters or malformed query strings).

Common situations: Hand-crafted or crawler HTTP requests with invalid percent-encoding; proxies forwarding raw, un-normalized URIs; fuzzing or security scanning tools hitting the file server.

Related errors


AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30). Data as JSON: /api/errors/9d3250daecc0bf46. Report an issue: GitHub.