Skip to content

XWIKI-23771: AWM: Numeric field accepts invalid characters, causing server error on edit#5830

Open
Sereza5 wants to merge 9 commits into
xwiki:masterfrom
Sereza5:XWIKI-23771
Open

XWIKI-23771: AWM: Numeric field accepts invalid characters, causing server error on edit#5830
Sereza5 wants to merge 9 commits into
xwiki:masterfrom
Sereza5:XWIKI-23771

Conversation

@Sereza5

@Sereza5 Sereza5 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Jira URL

https://jira.xwiki.org/browse/XWIKI-23771

Changes

Description

  • Render the AppWithinMinutes Number field as an HTML5 <input type="number"> instead of a plain text input, so browsers reject non-numeric input before the form is even submitted.
  • Replace the raw NumberFormatException-derived message in NumberClass.fromString() to a user-friendly XWikiException message
  • Added a Docker functional test NumberClassFieldIT

Clarifications

  • The actual change is contained in NumberClass and ApplicationResources, the other updates are just updates to existing tests and addition of a new test suite for the number class field in AWM.
  • The client-side type="number" change only prevents obviously invalid characters; it doesn't stop values that are valid HTML5 numbers but still overflow the configured number type (e.g. a huge integer for a long field). Those still reach the server, which is why the fromString() message fix is needed in addition to the input type change.
  • ApplicationClassEditPage.addFieldAndEditTemplate() was added as a page-object helper for the new test; it locates the class template link via its href (not its translated link text) since XWiki.ClassSheet names the template document <ClassName>Template and the template provider <ClassName>TemplateProvider (the latter is explicitly excluded from the selector).
  • NumberClassTest (existing unit test) was updated to mock ContextualLocalizationManager and match the new exception message format, since the previous assertions relied on the old raw message.

Screenshots & Video

xwiki-23771-comparison-export-trimmed

I tried making a skill with claude code to generate this comparison table directly from a test instance. Feel free to let me know if anything important is missing from this output. I'll test it on a few more PRs (and probably adjust it) before sharing it with the community. Without a skill or memory, it's quite expensive/long to obtain this result.

Executed Tests

  • mvn test -Dtest=NumberClassTest in xwiki-platform-core/xwiki-platform-oldcore passes
  • mvn test -Dtest='*ClassTest' in xwiki-platform-core/xwiki-platform-oldcore passes
  • mvn install (checkstyle included) in xwiki-platform-core/xwiki-platform-oldcore passes without violations
  • NumberClassFieldIT Docker functional test (xwiki-platform-appwithinminutes-test-docker) mvn clean verify -Dit.test=NumberClassFieldIT passes

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    • None.

Sereza5 added 9 commits July 2, 2026 17:42
…erver error on edit

* Added the proper type to the input
* Added an exception message that's straightforward
…erver error on edit

* Cleared up the checkstyle suppress
…erver error on edit * Fixed NumberClassTest for the new localized exception message
…erver error on edit * Reuse ClassSheetPage.clickTemplateLink() instead of a new page-object method
…erver error on edit

* Updated an incorrect translation value that ended in an unexpected double dot at the end with wrapping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant