Skip to content

Commit 34ee038

Browse files
Copilotsoxofaan
andauthored
Add stacktrace property to LogEntry (openEO API v1.3) (#892)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: soxofaan <44946+soxofaan@users.noreply.github.com>
1 parent 14cc3d7 commit 34ee038

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

openeo/rest/models/logs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class LogEntry(dict):
2222
between None and non-existing. None for example refers to no-data in
2323
many cases while the absence of the property means that the user did
2424
not provide any data for debugging.
25+
- ``stacktrace``: Stacktrace for the error, string, optional, available since API 1.3.0
2526
"""
2627

2728
_required = {"id", "level", "message"}
@@ -49,6 +50,11 @@ def message(self):
4950
def level(self):
5051
return self["level"]
5152

53+
@property
54+
def stacktrace(self) -> Union[str, None]:
55+
"""Stacktrace for the error, available since API 1.3.0. Returns None if not present."""
56+
return self.get("stacktrace", None)
57+
5258
# TODO: add properties for "code", "time", "path", "links" and "data" with sensible defaults?
5359

5460

tests/rest/models/test_logs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ def test_log_entry_legacy():
3636
assert log.log_id == "log01"
3737

3838

39+
def test_log_entry_stacktrace_missing():
40+
log = LogEntry(id="log01", level="error", message="oops")
41+
assert log.stacktrace is None
42+
43+
44+
def test_log_entry_stacktrace_present():
45+
log = LogEntry(
46+
id="log01",
47+
level="error",
48+
message="oops",
49+
stacktrace="line 1\nline 2\nline 3",
50+
)
51+
assert log.stacktrace == "line 1\nline 2\nline 3"
52+
assert log["stacktrace"] == "line 1\nline 2\nline 3"
53+
54+
3955
@pytest.mark.parametrize(
4056
["log_level_in", "expected_log_level"],
4157
[

0 commit comments

Comments
 (0)