Skip to content

[FR] [ISSUE] Cloud Function does not support FIRTimestamps (Support FIRTimestamps / Support Dates again) #1738

Open
@serjooo

Description

@serjooo

Environment

  • Xcode version: 9.4.1 (9F2000)
  • Firebase SDK version: 5.6.0
  • Firebase Component: FirebaseFunctions (2.1.0), FirebaseFirestore (0.13.1)

The problem

As I was calling a Cloud Function I received a fatal error saying:

'FIRInvalidArgumentException', reason: 'Unsupported type: NSDate

At first I thought it was Firestore throwing the exception as Firestore always recommended to use FIRTimestamps as Date objects will no longer be supported and might break in future releases. With this initial thought, I went ahead and updated my Model objects to start using FIRTimestamps. You might wonder why I updated my model objects? I have made my Model objects Codable with the help of a pod called https://github.com/alickbass/CodableFirebase to make it convenient to directly using structs or classes with Firestore, it worked with CloudFunctions as well. After using FIRTimestamp I got the same exception with unsupported type FIRTimestamp.

'FIRInvalidArgumentException', reason: 'Unsupported type: FIRTimestamp for value FIRTimestamp: seconds=1535053882 nanoseconds=638557910>'

Right now I'm stuck between having to rewrite all my CloudFunction dictionaries manually or write a method that makes sure FIRTimestamps are passed as String Date values or as milliseconds. This makes it very inconvenient to have conflicting requirements with both Google products.

Edit:

Realized NSDate was never supported to begin with. I broke my project by adding a date to the object and requiring it. Nevertheless, this is still a problematic issue.

Steps to reproduce:

Pass a Date object or FIRTimestamp object in the dictionary to a CloudFunction

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions