-
Notifications
You must be signed in to change notification settings - Fork 0
Description
SDK throws LithicInvalidDataException on created timestamp with >3 fractional digits
Summary
With responseValidation(true) enabled, the Java SDK rejects the created field in AccountHolderCreateResponse when Lithic returns a timestamp containing micro-second precision (6 fractional digits).
The API call itself succeeds (HTTP 200), but the client fails locally with:
com.lithic.api.errors.LithicInvalidDataException: Lithic validation error:
`created` is invalid, received 2025-07-04T16:42:33.360618
Steps to Reproduce
- Configure the client with eager response validation:
LithicClient client = LithicOkHttpClient.builder()
.apiKey("test_key")
.sandbox()
.responseValidation(true)
.build();
- Send a minimal KYB/KYC request:
Kyb kyb = Kyb.builder() .businessEntity(...) .controlPerson(...) .tosTimestamp("2022-03-08T08:00:00Z") .kybPassedTimestamp("2022-03-08T08:00:00Z") .workflow(Kyb.Workflow.KYB_BASIC) .build();
client.accountHolders().create(
AccountHolderCreateParams.builder().body(kyb).build()
);
- Lithic returns 200, but the SDK throws before returning the model.
Expected Behaviour
The SDK should accept the response (or at least not throw before the caller accesses the offending field) because the micro-second timestamp format is valid per Lithic docs and accepted by the server.
Actual Behaviour
SDK eagerly validates the response and rejects created values with more than 3 fractional digits.
Environment
| Item | Value |
|---|---|
| lithic-java | 0.94.1 (also reproduced on 0.93.x) |
| Java | Corretto 11.0.27 |
| OS | macOS 14.5 |
| Validation | responseValidation(true) |
Response Snippet
{
"created": "2025-07-04T16:42:33.360618",
...
}
Stack Trace
com.lithic.api.errors.LithicInvalidDataException: Lithic validation error: `created` is invalid, received 2025-07-04T16:42:33.360618
at com.lithic.api.core.JsonValue.validate(JsonValue.kt:47)
at com.lithic.api.models.AccountHolderCreateResponse.validate(AccountHolderCreateResponse.kt:108)
...
Workarounds
- Disable eager validation:
responseValidation(false), and then either - use
response.created.toString() - or catch
LithicInvalidDataExceptionand ignoreresponse.created()(less ideal).
Proposed Fix
Relax the regex / parsing for AccountHolderCreateResponse.created to allow up to 6 fractional digits (micro-seconds), or parse using DateTimeFormatter.ISO_OFFSET_DATE_TIME, which already tolerates 0-9 fractional digits.
Thanks!