Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arshedg opened this issue Nov 13, 2020 · 27 comments · Fixed by #1089
Assignees

Comments

@arshedg
Copy link

arshedg commented Nov 13, 2020

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

@google-oss-bot
Copy link

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.

@sulayyudiz
Copy link

I am also facing the same issue

@whereissami
Copy link

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

@evilass
Copy link

evilass commented Nov 13, 2020

We also facing this one since today.

@fkneist
Copy link

fkneist commented Nov 13, 2020

Same here

@WiNloSt
Copy link

WiNloSt commented Nov 13, 2020

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.

@VGJohn
Copy link

VGJohn commented Nov 13, 2020

Seeing this issue today as well

@ryanoboril
Copy link

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

@lukencrocker
Copy link

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.

@moshaheen
Copy link

Happening to us as well. just started today

@pedr0ni
Copy link

pedr0ni commented Nov 13, 2020

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

@leonardoj-cit
Copy link

leonardoj-cit commented Nov 13, 2020

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.

@lahirumaramba
Copy link
Member

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!

@moshaheen
Copy link

moshaheen commented Nov 13, 2020

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
Copy link

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.

@ryanoboril
Copy link

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.

@hiranya911
Copy link
Contributor

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

@ryanoboril
Copy link

Thank you so much. You all rock! 👍

lahirumaramba added a commit that referenced this issue Nov 13, 2020
@lahirumaramba
Copy link
Member

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.

@ajayagrawal
Copy link

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

@lahirumaramba
Copy link
Member

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?

@DavidMGini
Copy link

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.

@lahirumaramba
Copy link
Member

@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!

@DavidMGini
Copy link

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

@ajayagrawal
Copy link

ajayagrawal commented Dec 2, 2020

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

@lahirumaramba
Copy link
Member

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

@ajayagrawal
Copy link

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

BorntraegerMarc pushed a commit to BorntraegerMarc/firebase-admin-node that referenced this issue Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.