{"record":{"id":"be868170293ec1ae","repo":"theonedev/onedev","slug":"markupid-must-be-string-or-integer","errorCode":null,"errorMessage":"markupId must be String or Integer","messagePattern":"markupId must be String or Integer","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/apache/wicket/Component.java","lineNumber":2930,"sourceCode":"\t *            True is model strings should be escaped\n\t * @return This\n\t */\n\tpublic final Component setEscapeModelStrings(final boolean escapeMarkup)\n\t{\n\t\tsetFlag(FLAG_ESCAPE_MODEL_STRINGS, escapeMarkup);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set markup ID, which must be String or Integer\n\t * \n\t * @param markupId\n\t */\n\tpublic final void setMarkupIdImpl(Object markupId)\n\t{\n\t\tif (markupId != null && !(markupId instanceof String) && !(markupId instanceof Integer))\n\t\t{\n\t\t\tthrow new IllegalArgumentException(\"markupId must be String or Integer\");\n\t\t}\n\n\t\tsetOutputMarkupId(true);\n\t\tif (markupId instanceof Integer)\n\t\t{\n\t\t\tgeneratedMarkupId = (Integer)markupId;\n\t\t\tsetMetaData(MARKUP_ID_KEY, null);\n\t\t\treturn;\n\t\t}\n\n\t\tgeneratedMarkupId = -1;\n\t\tsetMetaData(MARKUP_ID_KEY, (String)markupId);\n\n\t}\n\n\t/**\n\t * Copy markupId\n\t * ","sourceCodeStart":2912,"sourceCodeEnd":2948,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/apache/wicket/Component.java#L2912-L2948","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"// before\ncomponent.setMarkupIdImpl(entity.getId()); // Long\n// after\ncomponent.setMarkupIdImpl(String.valueOf(entity.getId()));","handlingStrategy":"type-guard","validationCode":"if (id != null && !(id instanceof String) && !(id instanceof Integer)) { id = String.valueOf(id); }","typeGuard":"boolean validMarkupId(Object o) { return o == null || o instanceof String || o instanceof Integer; }","tryCatchPattern":"try { c.setMarkupIdImpl(raw); } catch (IllegalArgumentException e) { c.setMarkupId(String.valueOf(raw)); }","preventionTips":["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"],"tags":["wicket","markup-id","type","argument"],"backgroundTag":"type-mismatch","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}