Skip to content

Fix agent prosecutor authority access JSON parsing (CIMD-3294 regression) - #63

Merged
allanmckenzie merged 1 commit into
release/25.104.xfrom
dev/fix-agent-prosecutor-authority-json-parsing
Jul 14, 2026
Merged

Fix agent prosecutor authority access JSON parsing (CIMD-3294 regression)#63
allanmckenzie merged 1 commit into
release/25.104.xfrom
dev/fix-agent-prosecutor-authority-json-parsing

Conversation

@allanmckenzie

Copy link
Copy Markdown
Contributor

Problem

ProsecutingAuthorityProvider.buildFromResponseJson (access-control-sjp-providers) parsed the agentProsecutorAuthorityAccess response field as an array of JsonObjects, each expected to hold a prosecutingAuthority string property:

.map(agentAccess -> agentAccess.getValuesAs(JsonObject.class)
        .stream()
        .map(agent -> agent.getString("prosecutingAuthority"))
        .collect(Collectors.toList()))

But agentProsecutorAuthorityAccess is an array of strings. At runtime this throws:

java.lang.ClassCastException: org.eclipse.parsson.JsonStringImpl cannot be cast to jakarta.json.JsonObject

for any user with agent prosecutor access. It surfaced as HTTP 500s on cpp-context-mi-reportdata's SJP resulted-cases-count and case-export endpoints during the Java 25 / WildFly 40 upgrade (CasesCountIT.shouldVerifyResultedCasesCountMultipleAgents, CaseExportInJsonFormatExtractIT).

Where this code came from / root cause

The original, correct CIMD-3294 implementation on release/17.104.x-DD-41592 parsed the field as strings:

.map(arr -> arr.getValuesAs(JsonString.class)
        .stream()
        .map(JsonString::getString)
        .collect(Collectors.toList()))

When the feature was recreated on the 25.104.x line in commit 5f6e0925 ("Restore agent prosecutor authority access (CIMD-3294)"), the parsing was reimplemented with the wrong element type (JsonObject instead of JsonString) and no test was added for the agent-access path, so the regression shipped in 25.104.0-M7 unnoticed.

Fix

  • Restore the string-array parsing (getValuesAs(JsonString.class) + JsonString::getString) from release/17.104.x-DD-41592.
  • Add ProsecutingAuthorityProviderTest coverage: parse the string array into the access list, and grant access via an agent prosecutor authority. (Reproduces the CCE with the old code; green with the fix.)
  • Bump hearing.version 17.104.16817.104.176 in the root pom to satisfy enforce-moj-latest-interfaces (latest released hearing-query-api RAML).

Verification

  • Full cpp-platform-libraries reactor build green (enforcer on); ProsecutingAuthorityProviderTest 11/11, jacoco coverage met.
  • Proven end-to-end against mi-reportdata: patched only this class into the deployed WAR and re-ran the affected ITs — CaseExportInJsonFormatExtractIT 2/2 and CasesCountIT 5/5 (incl. …MultipleAgents) now pass.

🤖 Generated with Claude Code

…ion)

ProsecutingAuthorityProvider.buildFromResponseJson parsed the
agentProsecutorAuthorityAccess response field as an array of JsonObject
elements, each with a "prosecutingAuthority" property. The field is
actually an array of strings, so at runtime this threw
"ClassCastException: org.eclipse.parsson.JsonStringImpl cannot be cast
to jakarta.json.JsonObject" whenever a user had agent prosecutor access
(e.g. mi-reportdata sjp resulted-cases-count and case-export endpoints).

Restore the original, correct parsing from release/17.104.x-DD-41592
(getValuesAs(JsonString.class) + JsonString::getString). The commit that
recreated this CIMD-3294 feature on the 25.104.x line (5f6e092)
reimplemented the parsing with the wrong element type and added no test
for the agent-access path, so the regression shipped unnoticed.

Add ProsecutingAuthorityProviderTest coverage for parsing the string
array and for granting access via an agent prosecutor authority.

Bump hearing.version 17.104.168 -> 17.104.176 in the root pom to satisfy
enforce-moj-latest-interfaces (latest released hearing-query-api RAML).
@allanmckenzie
allanmckenzie requested a review from a team as a code owner July 14, 2026 09:28
@allanmckenzie
allanmckenzie requested review from oktayekincioglu, santhosh-hmcts and zozd-hmcts and removed request for a team July 14, 2026 09:28
@allanmckenzie
allanmckenzie merged commit 454ba0a into release/25.104.x Jul 14, 2026
1 of 2 checks passed
@allanmckenzie
allanmckenzie deleted the dev/fix-agent-prosecutor-authority-json-parsing branch July 14, 2026 10:10
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.

3 participants