Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

FINERACT-3392: Keep BigDecimal scale in partial responses - #7187

Open
Aana123 wants to merge 1 commit into
apache:developfrom
Aana123:FINERACT-3392-partial-response-bigdecimal
Open

Aana123 wants to merge 1 commit into
apache:developfrom
Aana123:FINERACT-3392-partial-response-bigdecimal

Conversation

@Aana123

@Aana123 Aana123 commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Fixes FINERACT-3392.

With ?fields=, every endpoint using @PartialResponseParameters (FINERACT-3188) wrote BigDecimal values in scientific notation: GET /groups/1/accounts returns "originalLoan":5000.000000, but ?fields=loanAccounts returned "originalLoan":5E+3. PartialResponseFilter builds the pruned response with objectMapper.valueToTree(entity), and by default Jackson strips the trailing zeros of each BigDecimal when it builds a tree (JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES).

The filter now uses its own copy of the ObjectMapper with that feature disabled:

  • Responses without fields= return before any tree is built, so they can't change.
  • The shared mapper is unchanged; only the filter's private copy is configured. The copy keeps the registered modules, so the date-array behaviour is unaffected.
  • Long, Integer and Double values are not affected (covered by the new test).

Affected endpoints are listed in the ticket (group/center accounts, GLIM/GSIM accounts, office transactions, loan collaterals, centers). None of them is in a release yet. #7186 (the loan reassignment template) uses the same filter and benefits as well.

Testing

  • PartialResponseFilterTest: two new tests, both failing before the fix.
    • aPrunedResponseKeepsTheScaleOfItsBigDecimalsAtEveryDepth asserts the exact pruned text for BigDecimals at scale 6 and 0, top-level, nested and in a list, next to Long, Integer and Double.
    • aResponseWithNothingToPruneIsWrittenAsTheUnfilteredOne requires a filtered response that prunes nothing to be identical to the unfiltered one.
  • SecurityApiGsonEquivalenceTest, ClientDataJsonFormatTest, JacksonWireFormatCharacterizationTest, spotless and checkstyle pass.
  • Live on a local build (PostgreSQL): /groups/1/accounts?fields=loanAccounts now returns "originalLoan":5000.000000, byte-identical to the unfiltered loanAccounts; fields=bogus still returns 400.

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
  • 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.

@Aana123 Aana123 changed the title INERACT-3392: Keep BigDecimal scale in partial responses FINERACT-3392: Keep BigDecimal scale in partial responses Dec 5, 2026
With ?fields=, PartialResponseFilter builds the pruned response with
objectMapper.valueToTree(entity). Jackson strips the trailing zeros of
each BigDecimal while it builds the tree
(JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES), so 500.000000 was
written as 5E+2 and 1000 as 1E+3, while the unfiltered response writes
them as they are.

The filter now uses its own copy of the ObjectMapper with that feature
disabled. Responses without fields= never reach this code, and the
shared mapper is unchanged. PartialResponseFilterTest asserts the exact
pruned text for BigDecimals at different scales and depths, next to
Long, Integer and Double values.
@Aana123
Aana123 force-pushed the FINERACT-3392-partial-response-bigdecimal branch from bc3881a to 6e4def7 Compare December 5, 2026 08:16
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