Conversation
TemplatesApiResource.saveTemplate never copied the templateId path
parameter onto the TemplateUpdateRequest, so TemplateDomainServiceImpl
updated whichever template id the client sent in the request body:
PUT /templates/1 with {"id": 2, ...} updated template 2. The body id was
also mandatory through a @NotNull whose message key was missing from
ValidationMessages.properties, so omitting it failed with the raw
{org.apache.fineract.infrastructure.template.id.not-null} key.
Set the payload id from the path before dispatching, drop the @NotNull
on TemplateUpdateRequest.id, and add the missing message, which
TemplateDeleteRequest still uses.
Assisted-By: claude-opus-5-5
rymghosn
force-pushed
the
port/FINERACT-2875-template-update-path-id
branch
from
September 30, 2026 09:04
db57c26 to
093d09f
Compare
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.
Description
JIRA: https://issues.apache.org/jira/browse/FINERACT-2875
PUT /v1/templates/{templateId}updates the template whose id is in the request body, not the one in the URL, and it rejects a request without a body id with an untranslated validation message:PUT /v1/templates/1with{"id": 2, ...}returns{"resourceId": 2}and updates template 2; template 1 is unchanged.PUT /v1/templates/1withoutidreturns 400 with the raw key{org.apache.fineract.infrastructure.template.id.not-null}as the error message.TemplatesApiResource.saveTemplatereceives thetemplateIdpath parameter but never copies it onto theTemplateUpdateRequestbefore dispatchingTemplateUpdateCommand, andTemplateDomainServiceImpl.updateTemplateloads the template byrequest.getId().TemplateUpdateRequest.idis@NotNull, so the body id is mandatory, and that constraint's message key is not defined inValidationMessages.properties.This PR:
saveTemplate, asdeleteTemplatealready does;@NotNullonTemplateUpdateRequest.id(bean validation runs before the method body, so it would otherwise keep the body id mandatory);org.apache.fineract.infrastructure.template.id.not-nullmessage, whichTemplateDeleteRequeststill uses.A client that already sends the matching id in the body is unaffected.
Testing
TemplatesApiResourceTest:saveTemplate(34L, request)with body id99dispatches a payload with id34. Ondevelopit fails (expected: 34L but was: 99L); with this PR all 5 tests in the class pass.bootRun, with two freshly created templates:develop(213f517b88):PUT /v1/templates/1with bodyid: 2returns 200{"resourceId": 2}and renames template 2; the same request withoutidreturns 400 with the raw message key above.PUT /v1/templates/3with bodyid: 4and withoutidboth return 200{"resourceId": 3}and update template 3; template 4 is unchanged.spotlessJavaCheckpasses.Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
idis no longer required and is ignored)Your assigned reviewer(s) will follow our guidelines for code reviews.