{"record":{"id":"fd5d98f6f48b753d","repo":"apache/maven","slug":"illegal-request-type-requesttype","errorCode":null,"errorMessage":"Illegal request type: \" + requestType","messagePattern":"Illegal request type: \" \\+ requestType","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java","lineNumber":138,"sourceCode":"        return requestType;\n    }\n\n    /**\n     * Sets the request type\n     *\n     * @param requestType The requestType to set.\n     *                    The Request type value should be either\n     *                    <code>TransferEvent.REQUEST_GET</code> or <code>TransferEvent.REQUEST_PUT</code>.\n     * @throws IllegalArgumentException when\n     */\n    public void setRequestType(final int requestType) {\n        switch (requestType) {\n            case REQUEST_PUT:\n                break;\n            case REQUEST_GET:\n                break;\n            default:\n                throw new IllegalArgumentException(\"Illegal request type: \" + requestType);\n        }\n\n        this.requestType = requestType;\n    }\n\n    /**\n     * @return Returns the eventType.\n     */\n    public int getEventType() {\n        return eventType;\n    }\n\n    /**\n     * @param eventType The eventType to set.\n     */\n    public void setEventType(final int eventType) {\n        switch (eventType) {\n            case TRANSFER_INITIATED:","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java#L120-L156","documentation":"Thrown by ArtifactTransferEvent.setRequestType() when the supplied type is neither TransferEvent.REQUEST_GET nor TransferEvent.REQUEST_PUT. This legacy event object validates its int constants through a switch with a default arm; any other int (including 0, the field default) is rejected with IllegalArgumentException naming the value. It guards event-consumer APIs (progress monitors, listeners) against meaningless request types.","triggerScenarios":"Constructing an ArtifactTransferEvent or calling setRequestType() with a raw int other than the two constants - e.g. passing eventType (0-4 range) where requestType is expected, or a default-initialized 0 leaked from a partially built event.","commonSituations":"Custom TransferListener implementations or wagon bridges creating events by hand; copy-paste swaps of setEventType/setRequestType arguments; deserialized/partial event objects whose requestType field was never set and is re-assigned via the setter.","solutions":["Always pass the constants: TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT","Audit call sites that build events for swapped arguments (requestType vs eventType are both ints)","Initialize requestType in the constructor rather than leaving 0 and setting later","Prefer the consumer-era org.eclipse.aether.TransferEvent API in new code; this legacy class is deprecated"],"exampleFix":"// before\nevent.setRequestType(event.getRequestType()); // or an unset 0 leaks in\nevent.setRequestType(someEventType);           // swapped argument\n// after\nimport static org.apache.maven.wagon.events.TransferEvent.REQUEST_GET;\nevent.setRequestType(REQUEST_GET);","handlingStrategy":"validation","validationCode":"static boolean isValidRequestType(int t) {\n    return t == org.apache.maven.wagon.events.TransferEvent.REQUEST_GET\n        || t == org.apache.maven.wagon.events.TransferEvent.REQUEST_PUT;\n}\nif (!isValidRequestType(requestType)) throw new IllegalArgumentException(\"...\" );","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use the REQUEST_GET/REQUEST_PUT constants, never raw ints","Review event-construction code for swapped setEventType/setRequestType args","Prefer the aether TransferEvent API with type-safe enums in new code"],"tags":["maven","transfer-event","validation","legacy","wagon"],"backgroundTag":"invalid-request-type","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}