googleworkspace / googleworkspace/apps-script-samples

form serializing not working for file type inputs; need unminified code to debug

Open
#132 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.2k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

I realize this is probably not the best place to ask this but I have no other avenues.

Per Google's HTML Service documentation:

If you call a server function with a form element as a parameter, the form becomes a single object with field names as keys and field values as values. The values are all converted to strings, except for the contents of file-input fields, which become Blob objects.

The relevant line in the code is:

function handleFormSubmit(formObject) {
    google.script.run.withSuccessHandler(updateUrl).processForm(formObject);
  }

And:

<form id="myForm" onsubmit="handleFormSubmit(this)">
  <input name="myFile" type="file" />
  <input type="submit" value="Submit" />
</form>

The issue is that in our organization (we use G-Suite) the call fails with this JavaScript error:

Exception: Invalid argument: blob

It is failing when trying to upload/serialize the file into a blob.

I know our organization is doing SOMETHING that is preventing the file from being uploaded/serialized. My challenge is that because I cannot find an unminified version of Google's code that is responsible for serializing/uploading the file, I cannot debug the root cause so I cannot identify what the SOMETHING our company is doing so I can talk to the relevant teams to fix.

I did some debugging using Chrome's developer console and this is the closest I can find for where the error is being raised/thrown:

function be(a, b) {
    b = Error(b);
    b.name = a;
    return b
}
  • a = "ScriptError"
  • b = "Exception: Invalid argument: blob"

There is a post on SO on this and I opened an issue but I have not had luck with either:

I am desperate to find a solution so I am hoping someone can either help me or point me in the right direction.

Expected Behavior

File should be uploaded, form data should be serialized, and sent to Google

Sample URL: https://github.com/gsuitedevs/apps-script-samples/blob/0ec9ff3bd109789668312cc2f0149f8187344b4f/ui/forms/index.html
Description:

Actual Behavior

JavaScript error:

Exception: Invalid argument: blob

Steps to Reproduce the Problem

  1. Publish code as web-app
  2. Go to web-app
  3. Select file and submit

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced samples/ui/forms/index.html and reproduce the web-app submission using the provided steps. Compare the observed "Exception: Invalid argument: blob" with the linked Google issue and Stack Overflow discussion; the report does not define a repository change or a verifiable completion condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.