twilio / twilio-java

A Java library for communicating with the Twilio REST API and generating TwiML.
MIT License
485 stars 427 forks source link

ConferenceReader date types do not match other reader types, preventing usage when trying to narrow API reads. #757

Closed NotQuiteApex closed 12 months ago

NotQuiteApex commented 1 year ago

Issue Summary

ConferenceReader tries to use a LocalDate field for query narrowing as if it were a temporal type with fields for time, rather than just date, which is unlike other reader types which use a ZonedDateTime field.

Steps to Reproduce

  1. Setup a Twilio app.
  2. Attempt to access resources like Recordings and, most importantly, Conferences.
  3. Take note that the "setDateCreated" methods for Readers are usually typed with ZonedDateTime. However, Conference.reader().setDateCreated() takes a LocalDate.

Code Snippet

...

final LocalDate date = LocalDate.EPOCH;
final ResourceSet<Conference> conferences = Conference.reader().setDateCreated(date).read();
// Exception above!

...

Exception/Log

java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: HourOfDay
    at java.base/java.time.LocalDate.get0(LocalDate.java:708)
    at java.base/java.time.LocalDate.getLong(LocalDate.java:687)
    at java.base/java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:308)
    at java.base/java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2702)
    at java.base/java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2341)
    at java.base/java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1843)
    at java.base/java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1817)
    at java.base/java.time.LocalDate.format(LocalDate.java:1816)
    at com.twilio.rest.api.v2010.account.ConferenceReader.addQueryParams(ConferenceReader.java:197)
    at com.twilio.rest.api.v2010.account.ConferenceReader.firstPage(ConferenceReader.java:126)
    at com.twilio.rest.api.v2010.account.ConferenceReader.read(ConferenceReader.java:105)
    at com.twilio.base.Reader.read(Reader.java:24)
    at [REDACTED].twilio.processor.SyncProcessor.doProcess(SyncProcessor.java:153)
...

The last line and beyond are just our application stack trace, a Dropwizard app, not relevant to this issue. Following the stacktrace it can be seen at addQueryParams that the LocalDate is expected to be formatable with a time component, which it cannot have because it's a LocalDate and not a LocalDateTime or ZonedDateTime (the latter being what other reader types use).

Technical details:

sbansla commented 1 year ago

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

sbansla commented 12 months ago

Issue was present in 9.9.0, This has been fixed now. You can use latest version. Currently latest version is 9.13.1