Skip to content

Add missing JSON.stringify in database:settings:set#3217

Merged
jmwski merged 4 commits into
masterfrom
jw/database-settings-set-fix
Mar 24, 2021
Merged

Add missing JSON.stringify in database:settings:set#3217
jmwski merged 4 commits into
masterfrom
jw/database-settings-set-fix

Conversation

@jmwski

@jmwski jmwski commented Mar 17, 2021

Copy link
Copy Markdown
Contributor

Description

Fixes #3228

The namespace server expects string-value .settings/<setting>.json values to be quoted. For defaultWriteSizeLimit, this meant that passing unlimited broke with this error log in firebase-debug.log:

[debug] [2021-03-17T22:10:45.519Z] <<< [apiv2][body] PUT https://fir-multi-shards.firebaseio.com/.settings/defaultWriteSizeLimit.json {"error":"defaultWriteSizeLimit should be one of {\"small\", \"unlimited\", \"large\", \"medium\"}"}
[debug] [2021-03-17T22:10:45.636Z] FirebaseError: HTTP Error: 400, defaultWriteSizeLimit should be one of {"small", "unlimited", "large", "medium"}
    at module.exports (/usr/local/google/home/wyszynski/.nvm/versions/node/v10.15.3/lib/node_modules/firebase-tools/lib/responseToError.js:38:12)
    at Client.doRequest (/usr/local/google/home/wyszynski/.nvm/versions/node/v10.15.3/lib/node_modules/firebase-tools/lib/apiv2.js:238:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)
[error]

Sample Commands

I tried setting the two supported database settings:

node ./lib/bin/firebase.js --project fir-multi-shards database:settings:set strictTriggerValidation false --instance fir-multi-shards

And:

node ./lib/bin/firebase.js --project fir-multi-shards database:settings:set defaultWriteSizeLimit unlimited --instance fir-multi-shards

And they both set the setting to the appropriate value. This change should also be robust to setting rules from the CLI.

@google-cla google-cla Bot added the cla: yes Manual indication that this has passed CLA. label Mar 17, 2021
@jmwski jmwski requested a review from bkendall March 17, 2021 23:07
@fredzqm

fredzqm commented Mar 17, 2021

Copy link
Copy Markdown
Contributor

Oh, maybe update the CHANGE_LOG.md

@bkendall bkendall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment on the changelog, but looks fine otherwise

Comment thread CHANGELOG.md Outdated
@jmwski jmwski merged commit 1826400 into master Mar 24, 2021
@jmwski jmwski deleted the jw/database-settings-set-fix branch March 24, 2021 16:18
devpeerapong pushed a commit to devpeerapong/firebase-tools that referenced this pull request Dec 14, 2021
* Add missing JSON.stringify in database:settings:set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Manual indication that this has passed CLA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When applying database settings the values aren’t stringified resulting in error.

4 participants