grahamearley / FirestoreGoogleAppsScript

A Google Apps Script library for accessing Google Cloud Firestore.
http://grahamearley.website/blog/2017/10/18/firestore-in-google-apps-script.html
MIT License
648 stars 109 forks source link

"Bad Request" Issue when updating / querying document information #165

Closed malek-ewa closed 10 months ago

malek-ewa commented 1 year ago

Minimal Code to Reproduce the Problem

  var firestore = FirestoreApp.getFirestore(FIRESTORE_EMAIL, FIRESTORE_PRIVATE_KEY, FIRESTORE_PROJECT_ID);
  var documents = firestore.query("CollectionName").Where("param_name", "==", param_value).Execute();

or

var document_id = "doc_id_1";
var param_value = "abcd";
var firestore = FirestoreApp.getFirestore(FIRESTORE_EMAIL, FIRESTORE_PRIVATE_KEY, FIRESTORE_PROJECT_ID);
var response = firestore.updateDocument("CollectionName/" + document_id, {"param_name" : param_value}, true);

Explain the Problem in Detail

The issue is not consistent, it does not happen every single time I call the "firestore.query" or the "firestore.updateDocument" functions, but it happens frequently enough (kind of randomly), for me to raise this issue. I see it occurring everyday at least 10-15 times in different Google App Scripts I'm using. The issue is basically that when I call those functions, a "Bad Request" error is thrown and the script crashes (see below screenshot for an example)

Bad_Request

For all cases, retriggering those same functions with the same parameters / document IDs works just fine. So it's some sort of temporary issue that goes away after a few seconds / minutes.

I'm not quite sure whether this is something about our Firebase maybe not having enough resources, or if it's something related to the fact that we're using App Script, but I wanted to ask in case someone here has faced the issue and knows what might be causing it and / or how I can get it resolved.

Other Comments

One way I thought of to fix this is add a retry mechanism everytime a "Bad Request" error is thrown, but this did not seem to be the right solution to me. That's why I'm asking, cause I'd like to get to the root cause of the issue and get that fixed if possible.

Library Version: 33

Thanks in advance.

abkarino commented 1 year ago

I had that happening to me and seems to be fixed automatically from google side. Can you confirm if it is already solved for you?

malek-ewa commented 10 months ago

Thanks for getting back @abkarino . Yes it's been a while that I haven't seen this error, so it might have been fixed on Google side as you mentioned. Thank you!