Skip to content

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

Closed

Description

@alexolivier

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

Activity

  1. stephenplusplus commented on Aug 17, 2016

    @stephenplusplus
    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?

  2. alexolivier commented on Aug 18, 2016

    @alexolivier
    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?

  3. stephenplusplus commented on Aug 18, 2016

    @stephenplusplus
    Contributor

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

  4. stephenplusplus commented on Aug 25, 2016

    @stephenplusplus
    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

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions