kataras/iris · error
%s: parameter type "%s" should be registered to the very end
Error message
%s: parameter type "%s" should be registered to the very end of a path once
What it means
Parse enforces that a trailing parameter type ({param:path}, the wildcard type) can only appear as the very last path segment. '%s: parameter type \"%s\" should be registered to the very end of a path once' fires when ast.IsTrailing(stmt.Type) is true but more path parts follow.
Source
Thrown at macro/interpreter/parser/parser.go:59
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)
}
return statements, nil
}
// ParamParser is the parser
// which is being used by the Parse function
// to parse path segments one by one
// and return their parsed parameter statements (param name, param type its functions and the inline route's functions).
type ParamParser struct {
src string
errors []string
}
// NewParamParser receives a "src" of a single parameterView on GitHub (pinned to 7bedaf55a0)
Solutions
- Move the {param:path} declaration to the final segment of the route.
- Handle any trailing differentiation inside the handler by inspecting the wildcard value.
- If both a specific sub-path and wildcard are needed, register them as separate routes (/files/{p:path} and /files/special).
Example fix
// before
app.Handle("/assets/{p:path}/index", serveIndex)
// after
app.Handle("/assets/{p:path}", serveAssets) // inspect p in handler
Defensive patterns
Strategy: validation
Validate before calling
func wildcardIsLast(p string) bool {
parts := strings.Split(strings.Trim(p, "/"), "/")
for i, s := range parts {
if strings.Contains(s, ":path}") && i != len(parts)-1 {
return false
}
}
return true
} Type guard
func isTrailingWildcardSegment(s string) bool { return strings.HasSuffix(s, ":path}") } Try / catch
if err := app.Build(); err != nil && strings.Contains(err.Error(), "should be registered to the very end") {
log.Fatalf("move wildcard param to the last segment: %v", err)
} Prevention
- Convention: {param:path} always last in route patterns.
- Differentiate sub-paths with separate route registrations.
- Test wildcard routes at build time in CI.
When it happens
Trigger: Registering routes like /static/{p:path}/index or /files/{f:path}/download — the :path (wildcard) param is followed by another segment. Detected at build time via Parse.
Common situations: Migrating wildcard routes from other frameworks that allow mid-path wildcards; typos leaving extra segments after a catch-all; generated routes appending suffixes after {param:path}.
Related errors
- %s: invalid path part: dynamic path parameter and other para
- errors joined from param parser: strings.Join(p.errors, "\n"
- no trailing path parameter found
- new route: %s conflicts with an already registered one: %s r
- %T does not allow any input arguments from route but got [le
AI-assisted analysis of kataras/iris@7bedaf55a0 (2026-08-30).
Data as JSON: /api/errors/a2d9ab5d566f623a.
Report an issue: GitHub.