Skip to content

Improve compatibility by ignoring invalid values instead of failing #158

@atschabu

Description

@atschabu

We keep running into compatibility issues, as various (test) environments have Locations and Tariffs with invalid information. This could range from completely wrong entries (country codes with more than 2 digits), easily ignorable issues (invalid enum value in optional field) to fixable issues (lat/lng with too many decimals)

Not only will this cause PUT/PATCH requests to fail, but also blocks paginated GET calls, as a single wrong field causes the entire call to be marked as invalid.

To improve compatibility, I'd suggest the following:

  • All deserialisers use Partials -> this allows filtering out bad entries from a list
  • All optional enums have a @JsonEnumDefaultValue UNKNOWN entry combined with DeserializationFeature#READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
  • Configurable validation that allows fixing values and ignoring UNKNOWN values instead of error

The execution chain for clients on GET would be

  • Deserialize Partial
  • Validate
    • optionally fixes issues
    • optionally ignores UNKNOWN and sets it to null
    • per entry, in case of list, and allows to filter invalid entries
  • convert to non-partial (can be code generated mapper)

The execution chain for server on PUT/PATCH/POST would be

  • transportServer handler
    • deserializes partial
  • service
    • validates with optional overrides and fixes
    • converts to non-partial

All these changes should be possible entirely within this lib, without affecting existing repo interfaces. Validation could be configured by either providing a Validator instance (instead of current static calls) or providing configuration in coroutine context

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