{"record":{"id":"de60bdaf238d0bad","repo":"kataras/iris","slug":"s-invalid-path-part-dynamic-path-parameter-and","errorCode":null,"errorMessage":"%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","messagePattern":"(.+?): invalid path part: dynamic path parameter and other parameters or static parts are not allowed in the same exact request path part, use the (.+?) function alone instead","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"macro/interpreter/parser/parser.go","lineNumber":45,"sourceCode":"\t\t\tcontinue\n\t\t}\n\n\t\t// if it's not a named path parameter of the new syntax then continue to the next\n\t\t// if s[0] != lexer.Begin || s[len(s)-1] != lexer.End {\n\t\t// \tcontinue\n\t\t// }\n\n\t\t// Modified to show an error on a certain invalid action.\n\t\tif s[0] != lexer.Begin {\n\t\t\tcontinue\n\t\t}\n\n\t\tif s[len(s)-1] != lexer.End {\n\t\t\tif idx := strings.LastIndexByte(s, lexer.End); idx > 2 && idx < len(s)-1 /* at least {x}*/ {\n\t\t\t\t// Do NOT allow something more than a dynamic path parameter in the same path segment,\n\t\t\t\t// e.g. /{param}-other-static-part/. See #2024.\n\t\t\t\t// this allows it but NO (see trie insert): s = s[0 : idx+1]\n\t\t\t\treturn 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)\n\t\t\t} else {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tp.Reset(s)\n\t\tstmt, err := p.Parse(paramTypes)\n\t\tif err != nil {\n\t\t\t// exit on first error\n\t\t\treturn nil, err\n\t\t}\n\t\t// if we have param type path but it's not the last path part\n\t\tif ast.IsTrailing(stmt.Type) && i < len(pathParts)-1 {\n\t\t\treturn nil, fmt.Errorf(\"%s: parameter type \\\"%s\\\" should be registered to the very end of a path once\", s, stmt.Type.Indent())\n\t\t}\n\n\t\tstatements = append(statements, stmt)\n\t}","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/macro/interpreter/parser/parser.go#L27-L63","documentation":"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).","triggerScenarios":"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.","commonSituations":"Trying to emulate pattern matching like /v{version}/resource; migrating from frameworks allowing mixed segments; auto-generated paths concatenating params with suffixes.","solutions":["Split mixed segments into separate static paths, or move the dynamic part to its own segment.","Use a single parameter with a regexp constraint instead: /file/{name:string regexp(...)}.","Handle suffix matching inside the handler (strip extensions manually) with a catch-all or string param.","Check each registered path: one dynamic parameter per segment, nothing else in that segment."],"exampleFix":"// before\napp.Get(\"/file/{name}.html\", h)\n// after\napp.Get(\"/file/{name:string regexp(^.*\\\\.html$)}\", h)","handlingStrategy":"validation","validationCode":"func validSegment(s string) error {\n    n := strings.Count(s, \"{\")\n    if n == 0 { return nil }\n    if n > 1 || strings.Trim(s, \"{}\") != paramOnly(s) {\n        return fmt.Errorf(\"segment %q mixes params with static text; use {param:string regexp(...)} instead\", s)\n    }\n    return nil\n}","typeGuard":"func isPureParamSegment(s string) bool {\n    return strings.HasPrefix(s, \"{\") && strings.HasSuffix(s, \"}\") && strings.Count(s, \"{\") == 1\n}","tryCatchPattern":"if err := app.Build(); err != nil && strings.Contains(err.Error(), \"invalid path part\") {\n    log.Fatalf(\"fix route path: %v\", err)\n}","preventionTips":["One dynamic parameter per path segment, nothing else in it.","Use {param:string regexp(...)} for pattern-within-segment needs.","Add a route-path linter/test that runs parser.Parse over all paths in CI."],"tags":["go","iris","routing","path-parameters","macro"],"backgroundTag":"invalid-route-path-segment","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}