Skip to content

Tidy up: gate discriminator-only short-circuit to simple-type variants (JtdSchema.java) #180

Open

Description

@simbo1905

Sub-issue 1 of 26 from the 2026-11-21 bot-review-comment audit. Parent issue: #179 (Bot review comment tidy up).
Audited origin/main HEAD: 2e5cf37. Audit date: 2026-11-21.

== Finding 1 (verbatim from the audit findings file) ==

  1. PR Fix discriminator validation for simple type mappings #95 — Ungated discriminator-only special-case bypasses required-property validation.
    Author: chatgpt-codex-connector[bot], 2025-09-28. Comment: Fix discriminator validation for simple type mappings #95 (comment)
    Source: json-java21-jtd/src/main/java/json/java21/jtd/JtdSchema.java:566. Current: json-java21-jtd/src/main/java/json/java21/jtd/JtdSchema.java:482-488 (DiscriminatorSchema.validate special-case; no rename, line drift only).
    Flagged: "shortcut returns success whenever a discriminator object contains only the discriminator key, regardless of what schema the key maps to... skips validation for all mappings, weakening schema enforcement and violating RFC 8927 semantics for object variants". Suggested: gate to simple-type variants.
    Still applies: current code still does if (obj.asMap().size() == 1 && obj.asMap().containsKey(disc)) return Result.success() unconditionally, so {"kind":"circle"} is accepted even when the mapping variant declares required properties. TestRfc8927 only exercises the shortcut with a variant that has no required properties.
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions