Harshitmehra-270709 opened a new pull request, #5596: URL: https://github.com/apache/fineract/pull/5596
## Description Fixes [FINERACT-2511](https://issues.apache.org/jira/browse/FINERACT-2511): Invalid `dateFormat` on client create returns HTTP 500 instead of 400 Bad Request. ### Root Cause When an invalid `dateFormat` value (e.g., `02 February 2026` instead of a valid pattern like `dd MMMM yyyy`) is provided in `POST /fineract-provider/api/v1/clients`, `ClientDataValidator.validateForCreate()` does not validate this parameter. The invalid value reaches `DateTimeFormatter.ofPattern(command.dateFormat())` in `ClientWritePlatformServiceJpaRepositoryImpl.createClient()`, which throws `IllegalArgumentException`. This uncaught exception surfaces as HTTP 500. ### Changes 1. **`DataValidatorBuilder.java`** - Added a reusable `validDateTimeFormatPattern()` method that validates date/time format pattern strings by attempting `DateTimeFormatter.ofPattern()` and catching `IllegalArgumentException`. This method follows the existing fluent API pattern and can be reused by other validators across the codebase. 2. **`ClientDataValidator.java`** - Added `dateFormat` validation in both `validateForCreate()` and `validateForUpdate()` using the new `validDateTimeFormatPattern()` method. Invalid patterns are now caught during validation and returned as HTTP 400 with a clear error message. 3. **`DataValidatorBuilderDateFormatTest.java`** [NEW] - 12 parameterized unit tests covering: - Valid patterns (`dd MMMM yyyy`, `yyyy-MM-dd`, `dd/MM/yyyy`, `MM/dd/yyyy`, `dd-MM-yyyy HH:mm:ss`) - Invalid patterns (`02 February 2026`, `not-a-pattern`, `P!@#$`, `{{invalid}}`) - Null value handling (with and without `ignoreIfNull`) - Blank value handling ### Testing - All 12 unit tests pass (0 failures, 0 errors) - `fineract-core:compileJava` BUILD SUCCESSFUL - Code formatted via `spotlessJavaApply` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
