Databricks: Invalid token, server shutdown and bad http path are not handled

Open
#407 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api, backend

Research direction

Start with pyhive/hive.py and thrift.transport.TTransport.TTransportBase.readAll, then inspect the TBinaryProtocol transport response fields described in the issue. Reproduce an invalid token, bad HTTP path, or shutting-down cluster case; done means the server's response information is surfaced instead of only EOFError.

Written by the indexing model from the issue text.

Description

In case when the token is invalid, just EOFError is raised, without any explanation. Though the response from a server contains a meaningful message.
TBinaryProtocol.trans contain code=403, message='forbidden' and headers. But never checked.

  File "pyhive/hive.py", line 104, in connect
    return Connection(*args, **kwargs)
  File "pyhive/hive.py", line 249, in __init__
    response = self._client.OpenSession(open_session_req)
  File "TCLIService/TCLIService.py", line 187, in OpenSession
    return self.recv_OpenSession()
  File "TCLIService/TCLIService.py", line 199, in recv_OpenSession
    (fname, mtype, rseqid) = iprot.readMessageBegin()
  File "thrift/protocol/TBinaryProtocol.py", line 148, in readMessageBegin
    name = self.trans.readAll(sz)
  File "thrift/transport/TTransport.py", line 68, in readAll
    raise EOFError()
EOFError

Same for bad HTTP path

put just 's' to HTTP path and other and keep other values from working connection settings
TBinaryProtocol.trans contain code=303, message='See other'

Same stack trace.

Also, EOFError raised when token invalidated after connection and when databricks cluster shutting down

The reason is thrift.transport.TTransport.TTransportBase.readAll just raises EOFError on the empty body regardless of response headers.

That may be the issue with thrift code.

Dominant language
Python
Stars
1.7k
Forks
545
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

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.

More from dropbox/PyHive

All issues in dropbox/PyHive

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.