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

  1. Convert the value: `component.setMarkupIdImpl(String.valueOf(id))` or cast/convert to Integer.
  2. Use the public setMarkupId(String) API instead of the internal *Impl variant.
  3. Null-check and type-check before calling: accept only String/Integer.
  4. If you have a Long, use `int i = longValue.intValue()` with range check, or prefer String.
  5. 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

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


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/be868170293ec1ae. Report an issue: GitHub.