Skip to content

Complete error message format consistency - add quotes to property names #105

Open

Description

@simbo1905

Issue: Complete error message format consistency

Location: json-java21-jtd/src/main/java/json/java21/jtd/Jtd.java

Current Status: ✅ COMPLETED

Changes Made:

  • MISSING_REQUIRED_PROPERTY: 'missing required property: %s' → 'missing required property: '%s''
  • ADDITIONAL_PROPERTY_NOT_ALLOWED: 'additional property not allowed: %s' → 'additional property not allowed: '%s''

Pattern Established:

  • User-provided string values (type names, property names, enum values, discriminator values) get single quotes
  • JSON class names (JsonNumber, JsonString, etc.) and type keywords (boolean, string, etc.) do NOT get quotes
  • This matches the existing pattern used by VALUE_NOT_IN_ENUM, DISCRIMINATOR_MUST_BE_STRING, etc.

Result:
✅ All tests pass. Error message format is now consistent across the codebase.

This issue is now resolved.

Activity

  1. changed the title [-]Simplify enum deduplication logic in JtdPropertyTest[/-] [+]Complete error message format consistency - add quotes to property names[/+] on Sep 28, 2025
  2. simbo1905 commented on Jan 26, 2026

    @simbo1905
    OwnerAuthor

    Analysis of Current State (main branch after PR #117 merge)

    Finding: Issue Appears Already Completed ✅

    Looking at the current code in json-java21-jtd/src/main/java/json/java21/jtd/Jtd.java (lines 745-786), the error messages already follow the consistent pattern described in this issue:

    Error messages WITH single quotes around user-provided values:

    Error Type Template
    UNKNOWN_TYPE "unknown type: '%s'"
    VALUE_NOT_IN_ENUM "value '%s' not in enum: %s"
    MISSING_REQUIRED_PROPERTY "missing required property: '%s'"
    ADDITIONAL_PROPERTY_NOT_ALLOWED "additional property not allowed: '%s'"
    DISCRIMINATOR_MUST_BE_STRING "discriminator '%s' must be a string"
    DISCRIMINATOR_VALUE_NOT_IN_MAPPING "discriminator value '%s' not in mapping"

    Error messages WITHOUT quotes (correct - these report Java class names/keywords, not user values):

    Error Type Template
    EXPECTED_BOOLEAN "expected boolean, got %s"
    EXPECTED_STRING "expected string, got %s"
    etc.

    Test Coverage Verified

    Tests in TestValidationErrors.java confirm the quoted format:

    • Line 151: assertThat(...).contains("missing required property: 'age'");
    • Line 173: assertThat(...).contains("additional property not allowed: 'extra'");

    Recommendation

    This issue can be closed - the changes described in the issue body are already implemented in the current main branch. The pattern is consistent: user-provided values (property names, type names, enum values) get single quotes, while Java type keywords don't.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions