adityamparikh opened a new pull request, #175:
URL: https://github.com/apache/solr-mcp/pull/175

   `JsonResponseParser` classifies JSON arrays purely by **shape**: an array of
   alternating `[String, non-String, ...]` pairs becomes a `NamedList`, anything
   else becomes a `List`. An empty array has no shape to inspect, so a facet on 
a
   field that matched zero documents is converted to an empty `List`.
   
   SolrJ's `QueryResponse` casts every `facet_counts/facet_fields` entry to
   `NamedList`, so that produces a **`ClassCastException` whenever a faceted 
field
   has no matches** — a plausible query, not an edge case:
   
   ```
   {"facet_counts":{"facet_fields":{"genre":[],"author":["asimov",3]}}}
                                             ^^ empty -> List -> CCE
   ```
   
   ### Fix
   
   Give the traversal positional context instead of guessing: thread the node 
path
   through `toNamedList`/`convertValue`, and treat anything directly under
   `facet_counts/facet_fields` as a `NamedList` regardless of shape. The 
existing
   shape heuristic still covers the other flat-NamedList sites.
   
   ### Tests
   
   Adds `JsonResponseParserTest` (5 cases), covering populated facets, the empty
   facet, empty/plain arrays *outside* `facet_fields` (which must stay `List`),
   and an end-to-end case that feeds the parsed response into a real
   `QueryResponse`.
   
   Verified against `main`: reverting only the `JsonResponseParser` change while
   keeping the new test fails 2 of the 5 cases, one of them with the
   `ClassCastException` above. With the fix, all 5 pass alongside the existing
   `JsonResponseParserContentTypesTest`.
   
   `./gradlew spotlessCheck test` is green.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to