Converting VARCHAR to TIMESTAMP with milleseconds yields "ERROR: date/time field value out of range"
Handling of date and timestamp input has been made stricter in Postgres 10. Quoting the release notes:


  Make to_timestamp() and to_date() reject out-of-range input
  fields (Artur Zakirov)
  
  For example, previously to_date('2009-06-40','YYYY-MM-DD') was
  accepted and returned 2009-07-10. It will now generate an error.


Explains what you observed. You'll need to sanitize your input.

Here is the thread where these changes were discussed.