{"record":{"id":"fe89295c4bd05657","repo":"kataras/iris","slug":"w-season-s","errorCode":null,"errorMessage":"%w: season: %s","messagePattern":"%w: season: (.+?)","errorType":"validation","errorClass":"ErrInvalid","httpStatus":null,"severity":"warning","filePath":"x/jsonx/season.go","lineNumber":119,"sourceCode":"\n\tdata = trimQuotes(data)\n\tif len(data) == 0 {\n\t\treturn nil\n\t}\n\n\tstr := string(data)\n\tconstantAsInt, err := strconv.Atoi(str)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif constantAsInt == 0 { // if 0 is passed, it means All seasons.\n\t\tconstantAsInt = int(AllSeasons)\n\t}\n\n\t*s = Season(constantAsInt)\n\tif !s.IsValid() {\n\t\treturn fmt.Errorf(\"%w: season: %s\", ErrInvalid, str)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":101,"sourceCodeEnd":124,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/x/jsonx/season.go#L101-L124","documentation":"Season is a bitmask (Winter=1, Spring=2, Summer=4, Autumn=8; 0 means AllSeasons). During UnmarshalJSON, after converting the JSON number to an int, IsValid() (s&AllSeasons==s) rejects any value that uses bits outside 1..15, wrapping ErrInvalid as \"invalid: season: %s\" with the original JSON text.","triggerScenarios":"Unmarshaling JSON like {\"season\": 16}, {\"season\": 32}, or any negative number into a struct field of type jsonx.Season.","commonSituations":"Client sending a wrong/out-of-range enum value; frontend treating season as a plain enum instead of a bitmask; API version drift where new bit values are invented.","solutions":["Send a valid bitmask value: 0/15 for all, 1..15 for combinations (e.g. 3 = Winter|Spring).","Validate the integer on the client before sending (0 <= v <= 15, or v == 0).","Accept the JSON as a number and construct with jsonx.Season(v) + IsValid() check on your side to produce a friendlier message."],"exampleFix":"// before\n{\"season\": 16} // invalid\n// after\n{\"season\": 15} // AllSeasons\n// or combine: 1|4 = 5 -> \"Winter, Summer\"","handlingStrategy":"validation","validationCode":"func validSeasonJSON(v int) bool { return v >= 0 && v <= 15 }\n// or with the library type: jsonx.Season(v).IsValid()","typeGuard":"func parseSeason(v int) (jsonx.Season, bool) {\n\ts := jsonx.Season(v)\n\tif v == 0 {\n\t\ts = jsonx.AllSeasons\n\t}\n\treturn s, s.IsValid()\n}","tryCatchPattern":"var p Payload\nif err := json.Unmarshal(data, &p); err != nil {\n\tif errors.Is(err, jsonx.ErrInvalid) && strings.Contains(err.Error(), \"season\") {\n\t\treturn fmt.Errorf(\"season must be a bitmask 0-15: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Document that Season is a bitmask (1|2|4|8, 0 = all)","Validate incoming JSON against a JSON schema limiting season to 0-15","Send string forms (\"Winter\") in APIs and map server-side"],"tags":["go","json","enum","bitmask","unmarshal"],"backgroundTag":"schema-validation-failed","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}