Firebase-admin-node: firebase remote config get template api fails throws "Version update time must be a valid date string"

Created on 13 Nov 2020  路  27Comments  路  Source: firebase/firebase-admin-node

Issue is reproducible in Firebase cloud function and in the local cloud function simulator(started occurring from 13-nov-2020)

  • Firebase SDK version: 9.4.0
  • Firebase Product: remote config
  • Node.js version: 10.10.0

Firebase node admin api "admin.remoteConfig().getTemplate() or config.getTemplateAtVersion" throws error

{"code":"remote-config/invalid-argument","message":"Version update time must be a valid date string"}

The issue is reproducible for all remote config versions updated today(using firebase ui or rest api).
Older remote config versions can be fetched.

config.getTemplateAtVersion(today's version) -> fails
config.getTemplateAtVersion(yesterday or previous version) -> works

Steps to reproduce:

update a remote config api using firebase ui.
get the template using the admin api

additional information

The version details of today's config(which doesn't work) look like

{
  "versionNumber": "7771",
  "updateTime": "2020-11-13T08:02:12.468168Z",
.....
}

Version details of old remote config (which work)

{
  "versionNumber": "7740",
  "updateTime": "2020-11-12T14:53:52.351Z",
...

You can see the time format is different for new and old remote config. I guess that's the reason why api is failing

remoteconfig

Most helpful comment

Thank you for reporting this issue!
We are currently working on a fix and this issue will track the progress. Thank you for your patience!

All 27 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

I am also facing the same issue

Experiencing same issue cant get remote config values in my cloud functions.

We also facing this one since today.

Same here

I'm also facing the same problem, I've debugging like crazy the past few hours until I found this issue.

For me, the parameter was added no longer than the past few hours. And the command

admin.remoteConfig().getTemplate()

Will fail with the same error described in the issue.

I've also tried downgrading firebase-admin to version 9.2.0, and 9.0.0 but doesn't really help.

Seeing this issue today as well

Same here, issue appeared overnight with no code changes or even npm update

Same issue here. Appeared overnight with no code changes. Tried all I can think of but still fails when hitting this line "admin.remoteConfig().getTemplate();" Only thing I did for it to start failing is add a new Remote Config setting as described.

Happening to us as well. just started today

Same issue here.

Stack trace:

PrefixedFirebaseError: Version update time must be a valid date string
at FirebaseRemoteConfigError.FirebaseError [as constructor] (/Users/matheusr/Documents/B2B/platform-config/mobile/firebase-autosync/node_modules/firebase-admin/lib/utils/error.js:43:28)
at FirebaseRemoteConfigError.PrefixedFirebaseError [as constructor] (/Users/matheusr/Documents/B2B/platform-config/mobile/firebase-autosync/node_modules/firebase-admin/lib/utils/error.js:89:28)
at new FirebaseRemoteConfigError (/Users/matheusr/Documents/B2B/platform-config/mobile/firebase-autosync/node_modules/firebase-admin/lib/remote-config/remote-config-api-client-internal.js:403:23)
at new VersionImpl (/Users/matheusr/Documents/B2B/platform-config/mobile/firebase-autosync/node_modules/firebase-admin/lib/remote-config/remote-config.js:297:23)
at new RemoteConfigTemplateImpl (/Users/matheusr/Documents/B2B/platform-config/mobile/firebase-autosync/node_modules/firebase-admin/lib/remote-config/remote-config.js:208:28)
at /Users/matheusr/Documents/B2B/platform-config/mobile/firebase-autosync/node_modules/firebase-admin/lib/remote-config/remote-config.js:61:20
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async getConfig (/Users/matheusr/Documents/B2B/platform-config/mobile/firebase-autosync/index.js:21:12)
at async main (/Users/matheusr/Documents/B2B/platform-config/mobile/firebase-autosync/index.js:48:28) {
errorInfo: {
code: 'remote-config/invalid-argument',
message: 'Version update time must be a valid date string'
},
codePrefix: 'remote-config'
}

I noticed that the problem seems to be related to the number of places used for the milliseconds
This is the version time that is being returned for me 2020-11-13T18:30:14.543720Z, for a valid ISO it should be just 3 instead of 6 before the Z, so 2020-11-13T18:30:14.543Z

The code falling is this one:

if (typeof version.updateTime !== 'undefined') {
            if (!validator.isISODateString(version.updateTime) &&
                !validator.isUTCDateString(version.updateTime)) {
                throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update time must be a valid date string');
            }
            if (validator.isISODateString(version.updateTime)) {
                // timestamps in output `Version` obtained from the API should be in UTC.
                this.updateTime = new Date(version.updateTime).toUTCString();
            }
        }

The isISODateString fails with 6 but works with 3 milliseconds places. No idea how that happened, any suggestions on how to fix this is appreciated.

Thank you for reporting this issue!
We are currently working on a fix and this issue will track the progress. Thank you for your patience!

The issue is happening because of isISODateString check
This should be a high priority ticket as it is breaking all code the depends on firebase remoteConfig

I noticed that the problem seems to be related to the number of places used for the milliseconds
This is the version time that is being returned for me 2020-11-13T18:30:14.543720Z, for a valid ISO it should be just 3 instead of 6 before the Z, so 2020-11-13T18:30:14.543Z

The code falling is this one:

if (typeof version.updateTime !== 'undefined') {
            if (!validator.isISODateString(version.updateTime) &&
                !validator.isUTCDateString(version.updateTime)) {
                throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update time must be a valid date string');
            }
            if (validator.isISODateString(version.updateTime)) {
                // timestamps in output `Version` obtained from the API should be in UTC.
                this.updateTime = new Date(version.updateTime).toUTCString();
            }
        }

The isISODateString fails with 6 but works with 3 milliseconds places. No idea how that happened, any suggestions on how to fix this is appreciated.

Yes, that is exactly the case.

I very much appreciate how quickly this was fixed! You developers are amazing 鉂わ笍

I see that the fix was merged, are you going to publish a new release of the firebase-admin npm? The latest is still 9.4.0, and this issue was closed.

I see that the fix was merged, are you going to publish a new release of the firebase-admin npm? The latest is still 9.4.0, and this issue was closed.

Yes, it's on the way. We are also following up with the backend team to figure out why the date format changed suddenly (and will continue to do so after the release too).

Thank you so much. You all rock! 馃憤

Thank you everyone for your patience! We have included the fix in 9.4.1.
We will continue to investigate the cause with the backend teams and will take measures to prevent any similar breaking changes in the future.

I am still facing this issue.

errorInfo:
{ code: 'remote-config/invalid-argument',
message: 'Version update time must be a valid date string' },
codePrefix: 'remote-config' }

I am still facing this issue.

errorInfo:
{ code: 'remote-config/invalid-argument',
message: 'Version update time must be a valid date string' },
codePrefix: 'remote-config' }

@ajayagrawal Thank you for letting us know. The initial issue should now be fixed in v9.4.1. If you are still seeing this issue, could you please provide us with more details? Do you see the above error when performing a specific operation?

Hi. I appreciate how fast this was solved.
Yet, I am facing the same issue.
I don't know how to upgrade to v9.4.1
Guess I have to, right now, otherwise my work is blocked.

@DavidMGini Unfortunately, you have to update firebase-admin to v9.4.1 to fix the issue. Start with a npm update firebase-admin@latest. Please let us know if you still see the error after updating. Thanks!

Updated - error went away immediately.
Much appreciated. :)

@lahirumaramba I am using the remote config fetch function as mention here:https://firebase.google.com/docs/remote-config/automate-rc and getting this error.
I have updated my firebase-admin as per your suggestion.

The complete error is as below:
Unable toget template { Error: Version update time must be a valid date string at FirebaseRemoteConfigError.FirebaseError [as constructor] (~mobile/iOS/backend/firebase_function/master_latest/functions/node_modules/firebase-admin/lib/utils/error.js:42:28) at FirebaseRemoteConfigError.PrefixedFirebaseError [as constructor] (~mobile/iOS/backend/firebase_function/master_latest/functions/node_modules/firebase-admin/lib/utils/error.js:88:28) at new FirebaseRemoteConfigError (~mobile/iOS/backend/firebase_function/master_latest/functions/node_modules/firebase-admin/lib/remote-config/remote-config-utils.js:43:23) at new VersionImpl (~mobile/iOS/backend/firebase_function/master_latest/functions/node_modules/firebase-admin/lib/remote-config/remote-config.js:287:23) at new RemoteConfigTemplateImpl (~mobile/iOS/backend/firebase_function/master_latest/functions/node_modules/firebase-admin/lib/remote-config/remote-config.js:198:28) at ~mobile/iOS/backend/firebase_function/master_latest/functions/node_modules/firebase-admin/lib/remote-config/remote-config.js:60:20 at process._tickCallback (internal/process/next_tick.js:68:7) errorInfo: { code: 'remote-config/invalid-argument', message: 'Version update time must be a valid date string' }, codePrefix: 'remote-config' }

@ajayagrawal Your node_modules could still be pointing to an older version of firebase-admin. Please try cleaning up the node_modules directory. You can also remove the package-lock.json and run npm install. Please note that this will reinstall all your dependencies so if you were using any specific versions of other dependencies in your project confirm them after the process is complete.

@lahirumaramba now it's working thanks for the help.

Was this page helpful?
0 / 5 - 0 ratings