'Why are google App scripts not stable for automation?
I'm testing a simple script to create Google App Script that triggers opening and updating GitHub issues upon submission of Google sheets,
If I test a working simple trigger like this one:
var ghToken = "my_GitHub_Token";
function onFormSubmit(e) {
var title = "This is a static title";
var body = "this is the body";
var payload = {
"title": title,
"body": body
};
var options = {
"method": "POST",
"headers": {
"authorization": "token "+ghToken
},
"contentType": "application/json",
"payload": JSON.stringify(payload)
};
var response = UrlFetchApp.fetch("https://api.github.com/repos/Example/Example/issues?access_token="+ghToken, options);
}
if I excute that trigger it works - BUT not stable each time, and there are missing responses in the post request for creating new issues,
it is even much worse if I try to pass responses from the Google form to the github fetch by any get request
so this trigger for example :
var ghToken = "my_GitHub_Token";
function onFormSubmit(e) {
var title = e.values[2];
var body = "this is the body";
var payload = {
"title": title,
"body": body
};
var options = {
"method": "POST",
"headers": {
"authorization": "token "+ghToken
},
"contentType": "application/json",
"payload": JSON.stringify(payload)
};
var response = UrlFetchApp.fetch("https://api.github.com/repos/Example/Example/issues?access_token="+ghToken, options);
}
The above trigger will not pass any responses in the issue, will even not post any issue at GitHub (unlike the first trigger with the static title). It fails to pass anything, and you can't find any faliures in the logs of that trigger to track where does it stop!
The Google App Script documentation seems to describe smooth operations, : https://developers.google.com/apps-script/guides/triggers/events#form-submit_1 - But it seems to be not that efficient in automation, and even a working useless trigger passing static titles and plain text seems not to succeed in the methods defined for the trigger each time.
I might be doing something wrong, but non of the available scripts online for the same purpose seem to work either , for example:
here: https://gist.github.com/bmcbride/62600e48274961819084 There: https://medium.com/@01010111/using-google-forms-to-submit-github-issues-efdb5f876b
And almost everywhere - none of them are functioning as described, I can't be copying and pasting wrong- since my control trigger (the first one) is worrking fine! and again not stable for each submission (it should open a new issue onFormSubmission, but it doesnt do that each time - some records on the sheet responses will miss an issue on GitHub) ..
Solution 1:[1]
Regarding not being stable, Google Apps Script is having problems, IMHO more than usual in the last few days.
Possible related issue reported yesterday and assigned
FormsApp: add setRespondentEmail() method(this is a feature request, not an issue)- Apps Script server rejects forms with a file input.
This issue is about HTML Service client-side code (google.script.run)
When having a service issue (something that only Google can fix) please search for similar issues on the apps script issue tracker and star them and if you didn't find any, post a new one.
Also keep an eye on Service Outage Log and on https://www.google.com/appsstatus/dashboard/
If you are using a Google Workspace account ask your Admin to send a support ticket.
You might also find helpful to analyse response which should be an HTTP response object. For this you might use console.log(response.getContentText())
Related
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
