ed-pilots-network / backend

Project to consume the Kafka, process the messages and provide an API to access the data
Apache License 2.0
12 stars 5 forks source link

Configurable JSON Deserialization Behavior for Environment-specific Handling of Unknown Properties #145

Closed pveeckhout closed 4 months ago

pveeckhout commented 4 months ago

Summary

We are seeking to enhance our application's resilience and development experience by introducing environment-specific behavior for JSON deserialization. Specifically, we would like the application to ignore unknown properties in JSON payloads in production environments (prod) to prevent exceptions and ensure smooth operation when consuming external APIs that may evolve. Conversely, in development (local) environments, we want to enforce strict checking, where any unknown properties in the payload would cause a deserialization exception, thus catching potential issues early during the development process. Current Behavior

Currently, our application's deserialization configuration is static and does not differentiate between development and production environments. This setup can lead to uncaught issues making their way into production or overly strict handling of API changes in production, potentially causing unnecessary failures. Desired Behavior

Suggested Implementation

We propose to utilize Spring Boot's profiles or a similar mechanism to dynamically configure Jackson's DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES based on the active environment. Here's a conceptual approach:

Impact

Implementing this feature will: