{"record":{"id":"a495bd8875baf3b9","repo":"pinpoint-apm/pinpoint","slug":"unknown-code","errorCode":null,"errorMessage":"Unknown code : ","messagePattern":"Unknown code : ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/model/basic/metric/group/MatchingRule.java","lineNumber":43,"sourceCode":"        this.code = code;\n        this.value = Objects.requireNonNull(value, \"value\");\n    }\n\n    public int getCode() {\n        return code;\n    }\n\n    public String getValue() {\n        return value;\n    }\n\n    public static MatchingRule getByCode(int code) {\n        for (MatchingRule matchingRule : MatchingRule.values()) {\n            if (matchingRule.code == code) {\n                return matchingRule;\n            }\n        }\n        throw new IllegalArgumentException(\"Unknown code : \" + code);\n    }\n\n    public static MatchingRule getByValue(String value) {\n        for (MatchingRule matchingRule : MatchingRule.values()) {\n            if (matchingRule.value.equalsIgnoreCase(value)) {\n                return matchingRule;\n            }\n        }\n        throw new IllegalArgumentException(\"Unknown value : \" + value);\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":55,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/web/model/basic/metric/group/MatchingRule.java#L25-L55","documentation":"MatchingRule.getByCode throws IllegalArgumentException when the given int code does not match the code of any MatchingRule enum constant. The enum maps numeric rule codes (e.g. from serialized request data) to matching-rule instances, and unknown codes are rejected.","triggerScenarios":"Calling MatchingRule.getByCode with a code outside the defined set — e.g. client sends ruleCode=7 while the enum only defines 0..n; deserializing old/new payloads whose codes don't match the deployed enum.","commonSituations":"Version skew between web frontend and backend after enum codes changed; hand-crafted API requests with guessed codes; stored dashboards persisting codes from a removed constant.","solutions":["Use only codes from the MatchingRule enum's defined constants (inspect MatchingRule.values() for valid code values).","Align frontend/backend versions so both share the same enum code set.","Catch IllegalArgumentException and fall back to a default matching rule.","Add the missing code as a new enum constant if the code is legitimately new."],"exampleFix":"// before\nMatchingRule rule = MatchingRule.getByCode(dto.getRuleCode());\n\n// after\nMatchingRule rule;\ntry {\n    rule = MatchingRule.getByCode(dto.getRuleCode());\n} catch (IllegalArgumentException e) {\n    rule = MatchingRule.DEFAULT;\n}","handlingStrategy":"try-catch","validationCode":"boolean valid = Arrays.stream(MatchingRule.values())\n    .anyMatch(r -> r.code == code);","typeGuard":null,"tryCatchPattern":"try {\n    rule = MatchingRule.getByCode(code);\n} catch (IllegalArgumentException e) {\n    rule = MatchingRule.DEFAULT;\n}","preventionTips":["Keep enum codes stable across releases; never renumber existing constants.","Keep client and server versions in sync.","Validate rule codes at the deserialization boundary."],"tags":["enum","argument-validation","metrics-web"],"backgroundTag":"invalid-enum-value","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}