Bug in `databricks.sql.exc.Error` base class
まだ誰も着手していません。
評価
調査の方向性
コネクタで databricks.sql.exc.Error クラスを検索し、その str メソッドと message_with_context メソッドを調べます。メッセージなしの Error を再現し、その後、文字列変換と message_with_context が失敗しなくなっていること、および既存のエラー動作が維持されていることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Problem: When try except catching errors and logging them I occasionally get this TypeError
...
try:
with connection.cursor() as cursor:
cursor.execute(query)
...
except databricks.sql.Error as e:
logger.debug(f"{str(e)}: failed to execute query {query}")
...
__str__ returned non-string (type NoneType)
Explanation:
String representations of a class must be of type string
the message attribute can be None therefore there needs to be a check/cast prior to returning.
Note: message_with_context will also fail when a message is None since you can't use the operand type + for NoneType and a str
class Error(Exception):
"""Base class for DB-API2.0 exceptions.
`message`: An optional user-friendly error message. It should be short, actionable and stable
`context`: Optional extra context about the error. MUST be JSON serializable
"""
def __init__(self, message=None, context=None, *args, **kwargs):
super().__init__(message, *args, **kwargs)
self.message = message
self.context = context or {}
def __str__(self):
return self.message
def message_with_context(self):
return self.message + ": " + json.dumps(self.context, default=str)
- 主要言語
- Python
- スター
- 233
- フォーク
- 152
- 平均マージ
- 21時間 5分
- マージ済み PR(30日)
- 10
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
databricks/databricks-sql-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
databricks/databricks-sql-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
PolicyEngine/policyengine-us#9559 ·
-
priority: p3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
googleapis/librarian#7636 ·
-
from:qa priority:P2 reliability tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spec-kitty/spec-kitty#4874 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100