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

BigQuery - running a large length query fails with HTTP400 #1503

Closed
alexolivier opened this issue Aug 17, 2016 · 4 comments
Closed

BigQuery - running a large length query fails with HTTP400 #1503

alexolivier opened this issue Aug 17, 2016 · 4 comments
Assignees
Labels
api: bigquery Issues related to the BigQuery API.

Comments

@alexolivier
Copy link

Running a BQ query is done via an HTTP GET which is failing on long queries as the URL is too long and rejected.

Environment details

  • OS: OSX
  • Node.js version: 6.0.0
  • npm version: 3.8.6
  • gcloud-node version: 0.37.0

Steps to reproduce

  1. require gcloud-node
  2. Run query that is very long (our example is 6325 characters long)
      bigquery.query(query, function (err, rows) {
        if (err) {
          reject(err)
          return
        }
        resolve(rows)
      })
  1. It will fail with an HTTP 400 - example response body
<HTML>\n<HEAD>\n<TITLE>Bad Request</TITLE>\n</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n<H1>Bad Request</H1>\n<H2>Error 400</H2>\n</BODY>\n</HTML>\n
@stephenplusplus
Copy link
Contributor

I wasn't able to reproduce with a 8,732 chars long query. We send the query string as part of the JSON payload of the HTTP request, so it's not in the URL itself. The 400 code has a few different meanings: https://cloud.google.com/bigquery/troubleshooting-errors -- any chance one of those could be related?

@stephenplusplus stephenplusplus added the api: bigquery Issues related to the BigQuery API. label Aug 17, 2016
@alexolivier
Copy link
Author

Confusingly, the same query runs fine in the BQ UI - any chance of getting error details in the response rather than an HTML payload?

@stephenplusplus
Copy link
Contributor

Currently, console.log(err) is that string of HTML?

@stephenplusplus
Copy link
Contributor

Since I can't get the same error you're getting, I forced another by using a malformed query. The error returned looks like this:

bigquery.query('malformed query', function(err) {})

console.log(err)

ApiError: Encountered " <ID> "malformed "" at line 1, column 1.
Was expecting:
    <EOF>

    at new util.ApiError (/Users/stephen/dev/play/gissue-1503/node_modules/@google-cloud/common/src/util.js:112:10)
    at Object.parseHttpRespBody (/Users/stephen/dev/play/gissue-1503/node_modules/@google-cloud/common/src/util.js:190:30)
    at Object.handleResp (/Users/stephen/dev/play/gissue-1503/node_modules/@google-cloud/common/src/util.js:130:18)
    at /Users/stephen/dev/play/gissue-1503/node_modules/@google-cloud/common/src/util.js:453:12
    at Request.onResponse [as _callback] (/Users/stephen/dev/play/gissue-1503/node_modules/retry-request/index.js:120:7)
    at Request.self.callback (/Users/stephen/dev/play/gissue-1503/node_modules/request/request.js:187:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/stephen/dev/play/gissue-1503/node_modules/request/request.js:1044:10)
    at emitOne (events.js:96:13)
  code: 400,
  errors:
   [ { domain: 'global',
       reason: 'invalidQuery',
       message: 'Encountered " <ID> "malformed "" at line 1, column 1.\nWas expecting:\n    <EOF> \n    ',
       locationType: 'other',
       location: 'query' } ],
  response: undefined,
  message: 'Encountered " <ID> "malformed "" at line 1, column 1.\nWas expecting:\n    <EOF> \n    ' }

I'm going to close since I can't reproduce. Let me know if you can provide a gist/repo that reproduces and I'll gladly re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API.
Projects
None yet
Development

No branches or pull requests

2 participants