This issue has been created
 
 
XWiki Commons / cid:jira-generated-image-avatar-3b4c1f94-1312-4d63-a640-209e0516be79 XCOMMONS-3847 Open

Invalid boolean and number values of a bean property are silently converted instead of failing

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-86cf50c5-08b4-4366-8406-882682e3df9b Charpentier Lucas created this issue on 21/Oct/26 17:26
 
Summary: Invalid boolean and number values of a bean property are silently converted instead of failing
Issue Type: cid:jira-generated-image-avatar-3b4c1f94-1312-4d63-a640-209e0516be79 Bug
Affects Versions: 17.10.14, 18.8.0
Assignee: Unassigned
Components: Properties
Created: 21/Oct/26 17:26
Priority: cid:jira-generated-image-static-major-c968e162-3a75-43e8-a215-219b1ac2e3d2 Major
Reporter: Charpentier Lucas
Description:

A macro parameter of type boolean or int accepts any value. A value that does not convert is replaced without an error: an unknown boolean becomes false and an invalid number becomes 0. The macro then runs with a value the user never typed, and nothing tells them the value was wrong.

Steps to reproduce

  1. Edit a page with the wiki editor.
  2. Add {{toc numbered="maybe"/}} and {{toc depth="abc"/}} on a page with headings.
  3. Save and view the page.

Expected

Both macros fail with a message saying that the value of the parameter cannot be converted.

Actual

  • The first table of contents renders unnumbered, as if numbered was false.
  • The second fails with "Failed to validate bean: [must be greater than or equal to 1]": abc was converted to 0, and only the @Min(1) constraint stopped it.

The WYSIWYG usability audit of the macros found the same on most of the 67 macros reviewed, for example wiki="abc" on the HTML macro, status="maybe" on the message macros, readOnly="maybe" on documentTree, which makes the tree editable, and count="abc" on notifications, which loops forever, see XWIKI-25412.

Lead

ConvertUtilsConverter registers the throwing BeanUtils converters in initialize(), on BeanUtilsBean.getInstance(), so that a failed conversion raises an error rather than returning a default value. That instance is kept per context class loader, so the conversions run under another context class loader may use the lenient default converters. The tests of ConvertUtilsConverter do not cover an invalid boolean or number.