theonedev/onedev · error · IllegalArgumentException
markupId must be String or Integer
Error message
markupId must be String or Integer
What it means
setMarkupIdImpl(Object) accepts only String or Integer markup ids (or null) and throws IllegalArgumentException for any other type. The value is used to set the generated/assigned markup id for output. Passing e.g. a Long, GUUID object, or arbitrary object fails the instanceof check.
Source
Thrown at server-core/src/main/java/org/apache/wicket/Component.java:2930
* True is model strings should be escaped
* @return This
*/
public final Component setEscapeModelStrings(final boolean escapeMarkup)
{
setFlag(FLAG_ESCAPE_MODEL_STRINGS, escapeMarkup);
return this;
}
/**
* Set markup ID, which must be String or Integer
*
* @param markupId
*/
public final void setMarkupIdImpl(Object markupId)
{
if (markupId != null && !(markupId instanceof String) && !(markupId instanceof Integer))
{
throw new IllegalArgumentException("markupId must be String or Integer");
}
setOutputMarkupId(true);
if (markupId instanceof Integer)
{
generatedMarkupId = (Integer)markupId;
setMetaData(MARKUP_ID_KEY, null);
return;
}
generatedMarkupId = -1;
setMetaData(MARKUP_ID_KEY, (String)markupId);
}
/**
* Copy markupId
* View on GitHub (pinned to d44925c47c)
Solutions
- Convert the value: `component.setMarkupIdImpl(String.valueOf(id))` or cast/convert to Integer.
- Use the public setMarkupId(String) API instead of the internal *Impl variant.
- Null-check and type-check before calling: accept only String/Integer.
- If you have a Long, use `int i = longValue.intValue()` with range check, or prefer String.
- Avoid reflection over Wicket internals; use documented APIs.
Example fix
// before component.setMarkupIdImpl(entity.getId()); // Long // after component.setMarkupIdImpl(String.valueOf(entity.getId()));
Defensive patterns
Strategy: type-guard
Validate before calling
if (id != null && !(id instanceof String) && !(id instanceof Integer)) { id = String.valueOf(id); } Type guard
boolean validMarkupId(Object o) { return o == null || o instanceof String || o instanceof Integer; } Try / catch
try { c.setMarkupIdImpl(raw); } catch (IllegalArgumentException e) { c.setMarkupId(String.valueOf(raw)); } Prevention
- Prefer public setMarkupId(String) over the internal Impl method
- Convert Long/UUID ids to String before assigning
- Document expected types in helpers wrapping Wicket internals
When it happens
Trigger: Calling setMarkupIdImpl with a Long/UUID/Object instead of String or Integer; framework/extension code passing numeric ids boxed as Long; reflection-based code setting ids from config values.
Common situations: Long database row ids passed directly instead of converted; generic setters forwarding Object args; third-party integrations misusing the internal API (it's meant for framework use).
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Markup id set on a component that renders its body only. Mar
- Replacement component must have the same id as the component
- cannot update component that does not have setOutputMarkupId
- Page classes should extend from BasePage.
- Base resource mapper should be used
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/be868170293ec1ae.
Report an issue: GitHub.