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

Limit Exceeded: URLFetch URL Length. in updateDocument with mask=true #54

Closed
lelesrc opened this issue Feb 21, 2019 · 3 comments · May be fixed by #144
Closed

Limit Exceeded: URLFetch URL Length. in updateDocument with mask=true #54

lelesrc opened this issue Feb 21, 2019 · 3 comments · May be fixed by #144

Comments

@lelesrc
Copy link

lelesrc commented Feb 21, 2019

When calling updateDocument with mask=true and a big set of fields to update, i got

Error in firestore.updateDocument: {"message":"Limit Exceeded: URLFetch URL Length.","name":"Exception","fileName":"Util (FirestoreApp)","lineNumber":25,"stack":"\tat Util (FirestoreApp):25 (fetchObject_)\n\tat Request (FirestoreApp):46\n\tat Request (FirestoreApp):98\n\tat Write (FirestoreApp):48 (updateDocument_)\n\tat Firestore (FirestoreApp):87\n}

There is an hard limit in URLFetch about url lenght:
https://issuetracker.google.com/issues/35892557
(This feature request is pending since 2012)

Inspecting the problem I noticed that fields to be masked in the update are added as request params in Write.js:

request.addParam('updateMask.fieldPaths', field)

Most probably my request exceeds the hard limit (in my use case, I need to update 60 over 63 fields in my doc, so the resulting url contains tens of fields).

I'm using version 22.

@LaughDonor
Copy link
Collaborator

This isn't a limitation of the library itself. However, since you are only updating certain fields, perhaps the best workaround (if anyone else comes across this) would be to split up the amount of fields to be updated and call .updateDocument multiple times.

@j05u3
Copy link

j05u3 commented Feb 11, 2021

May I suggest that another way around it would be this

@BoomerangTransport
Copy link

Hi everyone. I ran into the exact same issue, so I'm glad that this thread is here. Thank you lelesrc for raising it and explaining it so well. I appreciate LaughDonor acknowledging the issue as well and providing a possible workaround. Thank you to j05u3 for providing another possible workaround, which seems to be meant more for the library itself.

For anyone that runs into the same issue- I first solved this by creating a custom set of Firebase Functions that accomplished the same goal. That worked. But after creating them, I came back to this, found this thread, and set the mask parameter to false. Handpalm, that worked too. My guess is that the mask adds the fields to the request url from the body OR adds additional characters to the request that in my case pushed it just past the limit. Either way, in my one example, that fix happened to work. I'm leaving this in case it helps anyone else or if anyone has more detailed thoughts on how to solve / workaround this issue.

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.

4 participants