Skip to content

[java][bidi] Generated types mishandle special numbers and inbound nulls #18129

Open

Description

@titusfortner

Two defects in the generated Java BiDi types, verified on trunk after #17777. Both are Java-only; Python and Ruby already behave correctly.

  • NumberValue cannot carry a special number. Inbound {"type":"number","value":"NaN"} throws "value must be one of its declared union types"; outbound toMap() emits the raw SpecialNumber enum instead of "NaN". Regression against the hand-written API for any script.evaluate returning NaN or Infinity. Fix: in appendInlineUnionValidation, coerce a String through the enum arm's fromJson; in serializeExpr, add a union branch that calls toWireValue() on an enum arm. Failing test: NumberValueTest (two cases, both directions).
  • Inbound null handling. {"sharedId":"node","handle":null} decodes without error, though handle is not nullable (ADR 17786 decisions 4 and 7). Info.parent set to null and omitted both give parentSet == false, though the SetOverride plumbing exists. Fix: give every generated type its own fromJson, reject a present-but-null non-nullable field there, and pass Optional.of(map.containsKey(wire)) as the SetOverride argument. Keep ConstructorCoercer untouched; it is shared by all of Selenium Java.

Both tests belong in the generator suite proposed in #18128.

Activity

  1. yashp676 commented on Oct 9, 2026

    @yashp676
    Contributor

    Hi @titusfortner, Can I pick this up? I'd do the NumberValue fix first as its own PR (enum-arm coercion in appendInlineUnionValidation, toWireValue() in serializeExpr, with NumberValueTest covering both directions), then the null handling in a separate PR, since that one changes fromJson for every generated type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-javaJava BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions