Skip to content

feat(validation): oneOf near-miss validator hints + issues[].hint on every VALIDATION_ERROR #460

@bokelley

Description

@bokelley

Parent: #452

JS source

6.7 commit e7f8e228 (oneOf near-miss validator hint).

Pattern

When validation fails on a discriminated-union shape (e.g., pricing_options submitted with type instead of pricing_model), produce a hint naming the closest matching variant + which discriminator field is wrong.

Adopters hit this 3× before recovering — LLM clients especially. Adding a structured hint field on every validation-error issue lets the client surface it directly.

Proposed shape

Every issue inside a VALIDATION_ERROR envelope gets a hint field:

{
  "code": "VALIDATION_ERROR",
  "issues": [
    {
      "path": "pricing_options[0]",
      "message": "Required field 'pricing_model' missing",
      "hint": "Looks like you may have meant the 'cpm' variant. Use 'pricing_model' instead of 'type' as the discriminator."
    }
  ]
}

Heuristic: when a oneOf/discriminated-union shape fails, find the variant whose required-fields-present count is highest, and emit a hint naming it + which discriminator key the input is using.

Acceptance criteria

  • Hints appear on every VALIDATION_ERROR envelope where applicable.
  • Specifically tested for the v3 ref seller's pricing_options regression class of bug.
  • Hints are optional / additive — clients that ignore them work as before.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions