kataras/iris · error

%s: invalid path part: dynamic path parameter and other para

Error message

%s: invalid path part: dynamic path parameter and other parameters or static parts are not allowed in the same exact request path part, use the {regexp} function alone instead

What it means

Parse rejects path segments that mix a dynamic parameter with other parameters or static text, e.g. /files/{name}.txt or /{a}-{b}. The trie router cannot key a segment on a partial dynamic match, so Iris fails with '%s: invalid path part: dynamic path parameter and other parameters or static parts are not allowed in the same exact request path part, use the {regexp} function alone instead' (see issue #2024).

Source

Thrown at macro/interpreter/parser/parser.go:45

			continue
		}

		// if it's not a named path parameter of the new syntax then continue to the next
		// if s[0] != lexer.Begin || s[len(s)-1] != lexer.End {
		// 	continue
		// }

		// Modified to show an error on a certain invalid action.
		if s[0] != lexer.Begin {
			continue
		}

		if s[len(s)-1] != lexer.End {
			if idx := strings.LastIndexByte(s, lexer.End); idx > 2 && idx < len(s)-1 /* at least {x}*/ {
				// Do NOT allow something more than a dynamic path parameter in the same path segment,
				// e.g. /{param}-other-static-part/. See #2024.
				// this allows it but NO (see trie insert): s = s[0 : idx+1]
				return nil, fmt.Errorf("%s: invalid path part: dynamic path parameter and other parameters or static parts are not allowed in the same exact request path part, use the {regexp} function alone instead", s)
			} else {
				continue
			}
		}

		p.Reset(s)
		stmt, err := p.Parse(paramTypes)
		if err != nil {
			// exit on first error
			return nil, err
		}
		// if we have param type path but it's not the last path part
		if ast.IsTrailing(stmt.Type) && i < len(pathParts)-1 {
			return nil, fmt.Errorf("%s: parameter type \"%s\" should be registered to the very end of a path once", s, stmt.Type.Indent())
		}

		statements = append(statements, stmt)
	}

View on GitHub (pinned to 7bedaf55a0)

Solutions

  1. Split mixed segments into separate static paths, or move the dynamic part to its own segment.
  2. Use a single parameter with a regexp constraint instead: /file/{name:string regexp(...)}.
  3. Handle suffix matching inside the handler (strip extensions manually) with a catch-all or string param.
  4. Check each registered path: one dynamic parameter per segment, nothing else in that segment.

Example fix

// before
app.Get("/file/{name}.html", h)
// after
app.Get("/file/{name:string regexp(^.*\\.html$)}", h)
Defensive patterns

Strategy: validation

Validate before calling

func validSegment(s string) error {
    n := strings.Count(s, "{")
    if n == 0 { return nil }
    if n > 1 || strings.Trim(s, "{}") != paramOnly(s) {
        return fmt.Errorf("segment %q mixes params with static text; use {param:string regexp(...)} instead", s)
    }
    return nil
}

Type guard

func isPureParamSegment(s string) bool {
    return strings.HasPrefix(s, "{") && strings.HasSuffix(s, "}") && strings.Count(s, "{") == 1
}

Try / catch

if err := app.Build(); err != nil && strings.Contains(err.Error(), "invalid path part") {
    log.Fatalf("fix route path: %v", err)
}

Prevention

When it happens

Trigger: Registering routes such as app.Get("/{lang}-about", h), app.Get("/file/{name}.html", h), or any segment where '{param}' is concatenated with other characters/params. Detected at app build time when Parse processes the route path.

Common situations: Trying to emulate pattern matching like /v{version}/resource; migrating from frameworks allowing mixed segments; auto-generated paths concatenating params with suffixes.

Related errors


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