{"record":{"id":"39d2d5360880aa59","repo":"kataras/iris","slug":"errors-joined-from-param-parser-strings-join-p-er","errorCode":null,"errorMessage":"errors joined from param parser: strings.Join(p.errors, \"\\n\")","messagePattern":"errors joined from param parser: strings\\.Join\\(p\\.errors, \"\\\\n\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"macro/interpreter/parser/parser.go","lineNumber":105,"sourceCode":"func (p *ParamParser) Reset(src string) {\n\tp.src = src\n\tp.errors = []string{}\n}\n\nfunc (p *ParamParser) appendErr(format string, a ...any) {\n\tp.errors = append(p.errors, fmt.Sprintf(format, a...))\n}\n\nconst (\n\t// DefaultParamErrorCode is the default http error code, 404 not found,\n\t// per-parameter. An error code can be set via\n\t// the \"else\" keyword inside a route's path.\n\tDefaultParamErrorCode = 404\n)\n\nfunc (p ParamParser) Error() error {\n\tif len(p.errors) > 0 {\n\t\treturn errors.New(strings.Join(p.errors, \"\\n\"))\n\t}\n\treturn nil\n}\n\n// Parse parses the p.src based on the given param types and returns its param statement\n// and an error on failure.\nfunc (p *ParamParser) Parse(paramTypes []ast.ParamType) (*ast.ParamStatement, error) {\n\tl := lexer.New(p.src)\n\n\tstmt := &ast.ParamStatement{\n\t\tErrorCode: DefaultParamErrorCode,\n\t\tType:      ast.GetMasterParamType(paramTypes...),\n\t\tSrc:       p.src,\n\t}\n\n\tlastParamFunc := ast.ParamFunc{}\n\n\tfor {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/macro/interpreter/parser/parser.go#L87-L123","documentation":"This error is produced by the ParamParser in the route macro/path-template interpreter. It aggregates all individual parameter-validation failures collected while parsing a path parameter (e.g. an 'alphabetical' or 'int' macro failing) into a single error, one message per line, joined with '\\n'. It means one or more path parameter values in an incoming request did not satisfy the declared parameter type in the route's path template.","triggerScenarios":"A request arrives whose path parameter fails macro evaluation, e.g. route registered as '/users/{name:alphabetical}' and a request hits '/users/john123'; the failing macro appends a formatted error to p.errors, and Error() joins them. Multiple failing params in one route produce multiple lines.","commonSituations":"Developers register typed path parameters (macro syntax) and end users request URLs with values that don't match; also happens after changing a macro type (e.g. int -> alphabetical) while old clients still send numeric values.","solutions":["Check the multi-line message to see which parameter(s) failed and which macro was violated.","Fix the route path template to declare the correct parameter type for the data clients send.","Adjust client-side code to send values matching the macro (e.g. letters only for 'alphabetical').","If 404 DefaultParamErrorCode is undesirable, register a custom error handler / not-found handler on the router."],"exampleFix":"// before\napp.Get(\"/users/{name:alphabetical}\", handler) // clients send /users/123\n\n// after\napp.Get(\"/users/{name:alphabetical}\", handler)      // for names\napp.Get(\"/users/{id:uint}\", handler)                // for numeric IDs","handlingStrategy":"validation","validationCode":"// client-side check before calling an alphabetical route\nre := regexp.MustCompile(`^[a-zA-Z ]+$`)\nif !re.MatchString(name) {\n    name = strings.Join(strings.FieldsFunc(name, func(r rune) bool { return !unicode.IsLetter(r) && r != ' ' }), \"\")\n}","typeGuard":"func isAlphabetical(s string) bool { return regexp.MustCompile(`^[a-zA-Z ]+$`).MatchString(s) }","tryCatchPattern":null,"preventionTips":["Mirror the server macro regex in client-side URL builders.","Prefer simple types (string, uint) unless strict validation is required.","Register a friendly 404 handler so users see a helpful message."],"tags":["routing","path-parameters","validation","iris"],"backgroundTag":"route-param-validation-failed","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}