apache/maven · error · IllegalArgumentException
Illegal request type: " + requestType
Error message
Illegal request type: " + requestType
What it means
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.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java:138
return requestType;
}
/**
* Sets the request type
*
* @param requestType The requestType to set.
* The Request type value should be either
* <code>TransferEvent.REQUEST_GET</code> or <code>TransferEvent.REQUEST_PUT</code>.
* @throws IllegalArgumentException when
*/
public void setRequestType(final int requestType) {
switch (requestType) {
case REQUEST_PUT:
break;
case REQUEST_GET:
break;
default:
throw new IllegalArgumentException("Illegal request type: " + requestType);
}
this.requestType = requestType;
}
/**
* @return Returns the eventType.
*/
public int getEventType() {
return eventType;
}
/**
* @param eventType The eventType to set.
*/
public void setEventType(final int eventType) {
switch (eventType) {
case TRANSFER_INITIATED:View on GitHub (pinned to e4093d4e12)
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
Example fix
// before event.setRequestType(event.getRequestType()); // or an unset 0 leaks in event.setRequestType(someEventType); // swapped argument // after import static org.apache.maven.wagon.events.TransferEvent.REQUEST_GET; event.setRequestType(REQUEST_GET);
Defensive patterns
Strategy: validation
Validate before calling
static boolean isValidRequestType(int t) {
return t == org.apache.maven.wagon.events.TransferEvent.REQUEST_GET
|| t == org.apache.maven.wagon.events.TransferEvent.REQUEST_PUT;
}
if (!isValidRequestType(requestType)) throw new IllegalArgumentException("..." ); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Illegal event type: " + eventType
- artifactId can neither be null, empty nor blank
- version can neither be null, empty nor blank
- Unable to promptForPassword
- Unable to showMessage
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/fd5d98f6f48b753d.
Report an issue: GitHub.