Skip to content

gapps init causes syntax error if response body is not JSON #40

@jacktaylor418

Description

@jacktaylor418

I got a syntax error from the command gapps init 123...xyz (with "123...xyz" substituted by my real project ID). Here's the error:

[jack@mycomputer myproject]$ gapps init 123...xyz
Error parsing project files
Script file ID not found. Please input an ID and try again.
Error running init command
Unhandled rejection SyntaxError: Unexpected token <
    at Object.parse (native)
    at /usr/lib/node_modules/node-google-apps-script/lib/manifestor.js:79:19
    at tryCatcher (/usr/lib/node_modules/node-google-apps-script/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/usr/lib/node_modules/node-google-apps-script/node_modules/bluebird/js/main/promise.js:505:31)
    at Promise._settlePromiseAt (/usr/lib/node_modules/node-google-apps-script/node_modules/bluebird/js/main/promise.js:581:18)
    at Promise._settlePromises (/usr/lib/node_modules/node-google-apps-script/node_modules/bluebird/js/main/promise.js:697:14)
    at Async._drainQueue (/usr/lib/node_modules/node-google-apps-script/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/usr/lib/node_modules/node-google-apps-script/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/node-google-apps-script/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

After some digging, I found that JSON.parse in line 79 of manifestor.js was expecting JSON but actually received an HTML page. The HTML page was one saying "You need permission ... Want in? Ask the owner for access, or switch to an account with permission." I think I may have made a mistake when getting my credentials in the Google Developer Console, hence the authentication error.

It would be nice to handle this more elegantly, as the error message is pretty confusing - it makes it seem like the error is something to do with the project ID itself, when it is actually an authentication problem.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions