Skip to content

fix: widen ScoreAnswer.legend to Map<String, Object> for object and array levels - #13

Merged
garretpremo merged 1 commit into
mainfrom
fix/score-legend-object
Sep 22, 2026
Merged

garretpremo merged 1 commit into
mainfrom
fix/score-legend-object

Conversation

@garretpremo

Copy link
Copy Markdown
Contributor

Motivation:
Score levels are sent as any JSON value (List<Object>), and the API echoes them back in legend as sent. ScoreAnswer.legend was Map<String, String>, so a Score with an object or array level, including the one in Score's own javadoc example, failed the whole response with Cannot deserialize value of type java.lang.String from Object value, taking every other answer and usage with it. The API schema and both official SDKs allow string, object, or array legend values.

Changes:

  • ScoreAnswer.legend widened to Map<String, Object> in the record and its Jackson creator
  • Regression test with string, object, and array levels in one legend, asserting the sibling noul answer and usage survive
  • CHANGELOG entry

Binary-compatible under erasure; source-breaking only where a legend value was assigned directly to a String.

Fixes #11

…evels read back

Score levels are sent as any JSON value and the API echoes them back as
sent, but the legend was typed Map<String, String>. A Score with an
object or array level, including the one in Score's own javadoc example,
failed the whole response and every other answer with it (#11).
@garretpremo
garretpremo merged commit 81ceba1 into main Sep 22, 2026
1 check passed
garretpremo added a commit that referenced this pull request Sep 22, 2026
Choice<E> and ChoiceAnswer<E> carry the label type: build a question
from an enum's constants and read the answer back as that enum, with
probabilities keyed by it. String labels are unchanged. ChoiceAnswer's
type parameter changes the erased return type of choice(), so consumers
of 0.4.0 and earlier must recompile (#10, #15).

ScoreAnswer.legend is Map<String, Object>, so a Score with an object or
array level no longer fails the whole response (#11, #13). A response
missing usage, or a usage missing a token count, fails with a
TypeSafeException naming the field instead of reading as null or 0
(#12, #14). READMEs point at 0.5.0.
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.

ScoreAnswer.legend is typed Map<String, String>, but Score levels accept Object making the whole response undeserializable

1 participant