Skip to content

[fix] json serializable exception #4073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MonsterChenzhuo
Copy link

@MonsterChenzhuo MonsterChenzhuo commented Mar 24, 2025

What changes were proposed in this pull request?

Traceback (most recent call last):
File "/usr/share/hue/desktop/libs/notebook/src/notebook/decorators.py", line 120, in wrapper
return f(*args, **kwargs)
File "/usr/share/hue/desktop/libs/notebook/src/notebook/api.py", line 328, in fetch_result_data
response = _fetch_result_data(request, notebook, snippet, operation_id, rows=rows, start_over=start_over)
File "/usr/share/hue/desktop/libs/notebook/src/notebook/api.py", line 385, in _fetch_result_data
response['result']['data'] = escape_rows(response['result']['data'], nulls_only=nulls_only)
File "/usr/share/hue/desktop/libs/notebook/src/notebook/models.py", line 66, in escape_rows
escaped_field = json.dumps(field)
File "/usr/lib/python3.8/json/init.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type Decimal is not JSON serializable

How was this patch tested?

  • (Please explain how this patch was tested. Ex: unit tests, manual tests)
  • (If this patch involves UI changes, please attach a screen-shot; otherwise, remove this)

Please review Hue Contributing Guide before opening a pull request.

Copy link

⚠️ No unit test files modified. Please ensure that changes are properly tested. ⚠️

Copy link

Backend Codecov

Backend Code Coverage Report •
FileStmtsMissCoverMissing
desktop/libs/notebook/src/notebook
   models.py3614986%57, 61, 66, 69–70, 88–90, 162–163, 168, 235, 263–264, 266, 268, 343–345, 351–353, 361–362, 401–402, 410–411, 418–419, 426–427, 465–466, 473–474, 481–482, 515–516, 518, 546–547, 549, 584–587, 737
TOTAL533132612451% 

Pytest Report

Tests Skipped Failures Errors Time
1090 107 💤 0 ❌ 0 🔥 5m 45s ⏱️

@Harshg999
Copy link
Collaborator

Hey @MonsterChenzhuo, thanks for the fix!
Can you please tell us more about your use-case and issue description and steps to test out/repro the bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants