Skip to content

FINERACT-2875: Take the template id from the path on update - #6539

Open
rymghosn wants to merge 1 commit into
apache:developfrom
foodeveloper:port/FINERACT-2875-template-update-path-id
Open

rymghosn wants to merge 1 commit into
apache:developfrom
foodeveloper:port/FINERACT-2875-template-update-path-id

Conversation

@rymghosn

@rymghosn rymghosn commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

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/1 with {"id": 2, ...} returns {"resourceId": 2} and updates template 2; template 1 is unchanged.
  • PUT /v1/templates/1 without id returns 400 with the raw key {org.apache.fineract.infrastructure.template.id.not-null} as the error message.

TemplatesApiResource.saveTemplate receives the templateId path parameter but never copies it onto the TemplateUpdateRequest before dispatching TemplateUpdateCommand, and TemplateDomainServiceImpl.updateTemplate loads the template by request.getId(). TemplateUpdateRequest.id is @NotNull, so the body id is mandatory, and that constraint's message key is not defined in ValidationMessages.properties.

This PR:

  • sets the payload id from the path in saveTemplate, as deleteTemplate already does;
  • removes the @NotNull on TemplateUpdateRequest.id (bean validation runs before the method body, so it would otherwise keep the body id mandatory);
  • adds the missing org.apache.fineract.infrastructure.template.id.not-null message, which TemplateDeleteRequest still uses.

A client that already sends the matching id in the body is unaffected.

Testing

  • New test in TemplatesApiResourceTest: saveTemplate(34L, request) with body id 99 dispatches a payload with id 34. On develop it fails (expected: 34L but was: 99L); with this PR all 5 tests in the class pass.
  • Live on a local PostgreSQL instance booted with bootRun, with two freshly created templates:
    • develop (213f517b88): PUT /v1/templates/1 with body id: 2 returns 200 {"resourceId": 2} and renames template 2; the same request without id returns 400 with the raw message key above.
    • With this PR (templates 3 and 4): PUT /v1/templates/3 with body id: 4 and without id both return 200 {"resourceId": 3} and update template 3; template 4 is unchanged.
  • spotlessJavaCheck passes.

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes (not applicable: no endpoint or schema change; the body id is no longer required and is ignored)
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.
  • If merging this PR resolves a JIRA issue, I will mark that issue as resolved and set "Fix Version/s" appropriately.
  • I followed the AI Policy.

Your assigned reviewer(s) will follow our guidelines for code reviews.

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
rymghosn force-pushed the port/FINERACT-2875-template-update-path-id branch from db57c26 to 093d09f Compare September 30, 2026 09:04
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