[OLMIS-8223] Fix apostrophe bug in messages#24
Merged
Conversation
Overrode createMessageFormat in ExposedMessageSourceImpl files across 14 repos (auth, buq, cce, dhis2-integration, diagnostics, fulfillment, hapifhir, notification, referencedata, report, requisition, stockmanagement, template-service, one-network-integration-service).
When an exception with a Message invokes, @ControllerAdvice calls messageSource.getMessage(), which Spring resolves by calling createMessageFormat() — which I override.
It detects singular `'` in messages and converts them to `''`. Escaped `''` in messages remain unchanged.
To test I built requisition and referencedata, switched to :latest in ref-distro, then tested with requests:
```
GET /api/requisitions/search?requisitionStatus=BOGUS
Accept-Language: fr
Authorization: Bearer <token>
```
Response — 400 Bad Request:
```json
{
"messageKey": "requisition.error.validation.params.requisitionStatus.notValidStatus",
"message": "Le paramètre \"requisitionStatus\" n'est pas un Statut de Demande d'achat valide: [BOGUS]."
}
```
And:
```
POST /api/requisitions/initiate?facility=00000000-0000-0000-0000-000000000000&program=00000000-0000-0000-0000-000000000000&suggestedPeriod=00000000-0000-0000-0000-000000000000&emergency=false
Accept-Language: fr
Authorization: Bearer <token>
```
Response — 500 Internal Server Error (requisition wraps a 400 from referencedata):
```json
{
"status": 500,
"error": "Internal Server Error",
"message": "400 : [{\n \"messageKey\" : \"referenceData.error.program.notFound.with.id\",\n \"message\" : \"Impossible de trouver le programme avec l'ID : 00000000-0000-0000-0000-000000000000\"\n}]",
"path": "/api/requisitions/initiate"
}
```
Apostrophes are preserved, and `{0}` placeholders are replaced.
Includes unit test ExposedMessageSourceImplTest.
|
mgrochalskisoldevelo
approved these changes
May 15, 2026
mgrochalskisoldevelo
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Missing changelog entry, but that can be added during the release stage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Overrode createMessageFormat in ExposedMessageSourceImpl files across 14 repos (auth, buq, cce, dhis2-integration, diagnostics, fulfillment, hapifhir, notification, referencedata, report, requisition, stockmanagement, template-service, one-network-integration-service).
When an exception with a Message invokes, @ControllerAdvice calls messageSource.getMessage(), which Spring resolves by calling createMessageFormat() — which I override.
It detects singular
'in messages and converts them to''. Escaped''in messages remain unchanged.To test I built requisition and referencedata, switched to :latest in ref-distro, then tested with requests:
Response — 400 Bad Request:
{ "messageKey": "requisition.error.validation.params.requisitionStatus.notValidStatus", "message": "Le paramètre \"requisitionStatus\" n'est pas un Statut de Demande d'achat valide: [BOGUS]." }And:
Response — 500 Internal Server Error (requisition wraps a 400 from referencedata):
{ "status": 500, "error": "Internal Server Error", "message": "400 : [{\n \"messageKey\" : \"referenceData.error.program.notFound.with.id\",\n \"message\" : \"Impossible de trouver le programme avec l'ID : 00000000-0000-0000-0000-000000000000\"\n}]", "path": "/api/requisitions/initiate" }Apostrophes are preserved, and
{0}placeholders are replaced.Includes unit test ExposedMessageSourceImplTest.