Skip to content

fix: resolve OUG{} indicator count to zero when org unit has no group members [2.40]#24278

Open
jason-p-pickering wants to merge 1 commit into
2.40from
fix-oug-indicator-npe-2.40
Open

fix: resolve OUG{} indicator count to zero when org unit has no group members [2.40]#24278
jason-p-pickering wants to merge 1 commit into
2.40from
fix-oug-indicator-npe-2.40

Conversation

@jason-p-pickering

Copy link
Copy Markdown
Contributor

Summary

Backport of master commit 24aa365fe5 (PR #24266) onto 2.40 — the same fix that PR #24271 backports to 2.41.

ItemOrgUnitGroupCount.evaluate() threw ParserExceptionWithoutContext("Can't find count for organisation unit …") whenever orgUnitCountMap had no entry for the org unit being evaluated. That happens legitimately when an org unit's subtree contains no members of the group: the analytics org-unit target aggregation returns no row, so DataHandler passes a null (or entry-less) orgUnitCountMap into expression evaluation. The count should resolve to 0 in that case rather than throwing.

The fix reads the map defensively and returns 0d when the map is null or the entry is absent.

Testing

  • New ExpressionService2Test#testGetExpressionValueOrgUnitGroupCountMissingMemberCountIsZero covers both the null-map and missing-entry paths (12 * 0 = 0 via expressionH). Passes, along with the adjacent testGetExpressionValue.
  • Spotless clean.

Notes

  • The production hunk needed a trivial merge resolution (master had already hoisted the orgUnitCountMap local; the 3-way merge just needed the old throw block dropped). Result is byte-equivalent to the master fix.
  • Independent of, and complementary to, the OUG{} count-query performance work on downstream 2.40 branches (which is in the substituteIndicatorExpressions display path); this fix is in the analytics indicator-evaluation path.

Context: 2.40 is deprecated; this PR exists so the fix can be cleanly cherry-picked into downstream 2.40-based branches and is ready for any future 2.40 EOL update.

🤖 Generated with Claude Code

… members [2.40]

Backport of master commit 24aa365 (PR #24266) onto 2.40; equivalent to
the 2.41 backport in PR #24271.

ItemOrgUnitGroupCount.evaluate() threw a ParserExceptionWithoutContext
("Can't find count for organisation unit ...") whenever the orgUnitCountMap
had no entry for the org unit being evaluated. That happens legitimately for
an organisation unit whose subtree contains no members of the group: the
analytics org unit target aggregation returns no row, so DataHandler passes a
null (or entry-less) orgUnitCountMap down to expression evaluation. The count
should resolve to 0 in that case rather than throwing.

Now reads the map defensively and returns 0d when the map is null or the entry
is absent. New ExpressionService2Test case covers both the null-map and
missing-entry paths (12 * 0 = 0 via expressionH).

This is independent of and complementary to the OUG{} count-query performance
work already on the branch (substituteIndicatorExpressions path); this fix is
in the analytics indicator-evaluation path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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