firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

firebase remote config get template api fails throws "Version update time must be a valid date string"

Open arshedg opened this issue 6 years ago • 27 comments

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

arshedg avatar Nov 13 '20 08:11 arshedg

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.

google-oss-bot avatar Nov 13 '20 08:11 google-oss-bot

I am also facing the same issue

sulayyudiz avatar Nov 13 '20 10:11 sulayyudiz

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

whereissami avatar Nov 13 '20 12:11 whereissami

We also facing this one since today.

evilass avatar Nov 13 '20 12:11 evilass

Same here

fkneist avatar Nov 13 '20 12:11 fkneist

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.

WiNloSt avatar Nov 13 '20 13:11 WiNloSt

Seeing this issue today as well

VGJohn avatar Nov 13 '20 16:11 VGJohn

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

ryanoboril avatar Nov 13 '20 16:11 ryanoboril

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.

lukencrocker avatar Nov 13 '20 17:11 lukencrocker

Happening to us as well. just started today

moshaheen avatar Nov 13 '20 17:11 moshaheen

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' }

pedr0ni avatar Nov 13 '20 18:11 pedr0ni

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.

leonardoj-cit avatar Nov 13 '20 18:11 leonardoj-cit

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!

lahirumaramba avatar Nov 13 '20 19:11 lahirumaramba

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

moshaheen avatar Nov 13 '20 19:11 moshaheen

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.

moshaheen avatar Nov 13 '20 19:11 moshaheen

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.

ryanoboril avatar Nov 13 '20 22:11 ryanoboril

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).

hiranya911 avatar Nov 13 '20 22:11 hiranya911

Thank you so much. You all rock! 👍

ryanoboril avatar Nov 13 '20 22:11 ryanoboril

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.

lahirumaramba avatar Nov 13 '20 22:11 lahirumaramba

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 avatar Nov 30 '20 10:11 ajayagrawal