logging library doesn't support Exceptions
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 52/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 冷清
- 技術堆疊
- python
研究方向
從 firebase_functions/logger.py 開始,特別查看 error()、write() 和 _entry_from_args(),然後將文件中的 Firebase 記錄日誌範例與此處顯示的 JSON 序列化失敗進行比較。完成條件是:記錄 Exception 不再拋出錯誤,且記錄日誌 API 會在函式日誌中包含 Exception 的完整堆疊追蹤。
由索引模型根據 Issue 內容生成。
描述
The logger in firebase_functions doesn't seem to provide reasonable support for exceptions.
In the example, firebase suggests extracting a portion of the error and including it:
try
...
except:
e = sys.exc_info()[0]
# Attach an error object as the second argument
logger.error("Unable to read quote from Firestore, sending default instead", error=e)
However this fails with an error:
../../../../Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/firebase_functions/logger.py:130: in error
write(_entry_from_args(LogSeverity.ERROR, *args, **kwargs))
../../../../Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/firebase_functions/logger.py:95: in write
print(_json.dumps(_remove_circular(entry)), file=write_file)
../../../../.pyenv/versions/3.11.7/lib/python3.11/json/__init__.py:231: in dumps
return _default_encoder.encode(obj)
../../../../.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:200: in encode
chunks = self.iterencode(o, _one_shot=True)
../../../../.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:258: in iterencode
return _iterencode(o, 0)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <json.encoder.JSONEncoder object at 0x10166ee10>, o = <class 'TypeError'>
def default(self, o):
"""Implement this method in a subclass such that it returns
a serializable object for ``o``, or calls the base implementation
(to raise a ``TypeError``).
For example, to support arbitrary iterators, you could
implement default like this::
def default(self, o):
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
# Let the base class default method raise the TypeError
return JSONEncoder.default(self, o)
"""
> raise TypeError(f'Object of type {o.__class__.__name__} '
f'is not JSON serializable')
E TypeError: Object of type type is not JSON serializable
../../../../.pyenv/versions/3.11.7/lib/python3.11/json/encoder.py:180: TypeError
Moreover it's not really an ideal API to log a subset of an exception. Ideally the entire stack trace would be included.
If you instead simply print the error, you can see a reasonable stack trace in the logs for the function.
I'd expect the example to not throw. I'd also expect the logging API to explicitly support logging Exceptions with stack traces
- 主要語言
- Python
- 星號
- 167
- 分支
- 36
- 平均合併
- 4 天 3 小時
- 30 天內合併 PR
- 1
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
firebase/firebase-functions-python 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 84/100
-
HttpsError.__init__ does not pass message to super().__init__()可能已有人在做 @Aayush99910 於 4 天前認領。 未關閉
難度 1/5 1 小時以內 新手友好度 85/100
firebase/firebase-functions-python#314 · 1 則留言 ·
-
Add support for VPC direct connect可能已有人在做 @IzaakGough 於 108 天前認領。 未關閉feature-request
難度 4/5 3-5 天 新手友好度 48/100
firebase/firebase-functions-python#275 · 1 則留言 · 1 個 reaction ·
-
feature-request
難度 4/5 3-5 天 新手友好度 35/100
firebase/firebase-functions-python#271 · 3 則留言 ·
-
[Bug] stability_digest_payload_from_ce_payload fails with AttributeError: 'dict' object has no attribute 'split'可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug unable to reproduce
難度 3/5 1-2 天 新手友好度 55/100
firebase/firebase-functions-python#260 · 6 則留言 ·
查看 firebase/firebase-functions-python 的全部 Issue
相似的 Issue
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_wait未關閉needs-triage
難度 2/5 1-3 小時 新手友好度 77/100
krkn-chaos/krkn#1627 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
NousResearch/hermes-agent#136483 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 1 天內回覆
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last element可能已有人在做 @peterdsharpe 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 78/100
pytorch/tensordict#2307 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆