E52F FINERACT-1556: treat template runreports as parameter metadata by Satish11012007 · Pull Request #5606 · apache/fineract · GitHub
[go: up one dir, main page]

Skip to content

FINERACT-1556: treat template runreports as parameter metadata#5606

Open
Satish11012007 wants to merge 1 commit intoapache:developfrom
Satish11012007:fix/FINERACT-1556-stretchy-reports-postgres
Open

FINERACT-1556: treat template runreports as parameter metadata#5606
Satish11012007 wants to merge 1 commit intoapache:developfrom
Satish11012007:fix/FINERACT-1556-stretchy-reports-postgres

Conversation

@Satish11012007
Copy link
Contributor

Description

This PR fixes an issue where calling the Stretchy Reports endpoint with template=true still attempted to execute the underlying SQL query.

Stretchy report queries often contain placeholders such as ${officeId}{} or ${currencyId}{} which are meant to be replaced with request parameters. When template=true is used, the expected behavior is to return report parameter metadata without executing the SQL query.

However, the existing implementation did not properly handle the template flag. As a result, the SQL query was executed with unresolved placeholders, which caused PostgreSQL to throw errors such as:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "$"

This PR resolves the issue by ensuring that when template=true is present in the request and parameterType is not explicitly provided, the system automatically treats the request as a parameter metadata request by setting parameterType=true.

This prevents SQL execution and returns the required report parameter metadata as intended.

Fixes: FINERACT-1556

Changes Made

  • Updated RunreportsApiResource.processReportRequest to ensure that template=true implies parameterType=true when parameterType is not explicitly provided.
  • Prevented execution of report SQL queries when the request is meant to fetch parameter metadata.
  • Added regression tests to validate correct propagation of the template flag.

Files Modified

  • fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResource.java
  • fineract-provider/src/test/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResourceTest.java

Testing

Added unit tests to verify that requests with template=true correctly propagate as parameterType=true.

Commands used:

./gradlew :fineract-provider:test --tests org.apache.fineract.infrastructure.dataqueries.api.RunreportsApiResourceTest

./gradlew :fineract-provider:test

Result:

All tests passed successfully.

How to Verify

Call the following API:

GET /fineract-provider/api/v1/runreports/Active%20Loans%20-%20Details?template=true

Expected behavior:

  • The API returns report parameter metadata
  • The SQL query is not executed
  • No PostgreSQL $ placeholder errors occur

Checklist

  • Write the commit message as per our guidelines
  • Ensure the build passes successfully
  • Create/update unit tests verifying the changes
  • Follow Apache Fineract coding conventions
  • Add Swagger annotation / API documentation update (not required as no API contract change)
  • PR is focused and not a code dump

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

0