quarkusio/quarkus · warning · AssertionError

Default mapper cannot process date/time properties. So we we

Error message

Default mapper cannot process date/time properties. So we were expecting transaction to fail, but it did not!

What it means

This endpoint intentionally stores an entity whose JSON mapper cannot handle date/time properties; the test expects flush() to fail with UnsupportedOperationException ('I cannot convert anything to JSON'). If no exception was thrown, the guard the test relies on is missing and it throws this AssertionError.

Source

Thrown at integration-tests/jpa-postgresql/src/main/java/io/quarkus/it/jpa/postgresql/JPAFunctionalityTestEndpoint.java:167

        });

        QuarkusTransaction.requiringNew().run(() -> {
            em.createQuery("delete from EntityWithJson").executeUpdate();
        });

        Exception exception = null;
        try {
            QuarkusTransaction.requiringNew().run(() -> {
                EntityWithJsonOtherPU otherPU = new EntityWithJsonOtherPU(
                        new EntityWithJsonOtherPU.ToBeSerializedWithDateTime(LocalDate.of(2023, 7, 28)));
                otherEm.persist(otherPU);
            });
        } catch (Exception e) {
            exception = e;
        }

        if (exception == null) {
            throw new AssertionError(
                    "Default mapper cannot process date/time properties. So we were expecting transaction to fail, but it did not!");
        }
        if (!(exception instanceof UnsupportedOperationException)
                || !exception.getMessage().contains("I cannot convert anything to JSON")) {
            throw new AssertionError("flush failed for a different reason than expected.", exception);
        }

        return "OK";
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the default JSON mapper in use is the one that rejects date/time types (throws 'I cannot convert anything to JSON')
  2. Check dependency versions (hibernate-reactive / hypersistence-utils) for changed JSON mapper behavior
  3. Confirm the json column actually goes through the JSON mapper (right @JdbcTypeCode/dialect) rather than being stored as text
  4. Update the test expectation if the library now legitimately supports date/time serialization

Example fix

// before
if (exception == null) {
    throw new AssertionError("expecting transaction to fail, but it did not!");
}
// after (diagnose what actually happened)
if (exception == null) {
    throw new AssertionError("expecting transaction to fail, but it did not! Mapper=" + mapper.getClass());
}
Defensive patterns

Strategy: try-catch

Validate before calling

// confirm mapper behavior before relying on it
try {
    mapper.toJson(Map.of("d", LocalDate.now()));
    throw new IllegalStateException("Mapper unexpectedly supports dates; test premise invalid");
} catch (UnsupportedOperationException expected) { /* good */ }

Try / catch

try {
    QuarkusTransaction.requiringNew().run(() -> { em.persist(e); em.flush(); });
} catch (UnsupportedOperationException uoe) {
    // expected when default mapper meets date/time properties
}

Prevention

When it happens

Trigger: Persisting an EntityWithJson containing LocalDate/LocalDateTime with the default (non-date-aware) JSON mapper, then flushing, and the operation unexpectedly succeeds — mapper configuration changed or dates were silently serialized.

Common situations: Upgrading Hibernate Reactive/hibernate-types so date/time JSON support changed, swapping the default ObjectMapper for one that serializes dates, or dialect changes making the column a plain varchar.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/3067f26bb0c25a29. Report an issue: GitHub.