Skip to content
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

TypeError: Object of type OnCallError is not JSON serializable #5124

Closed
senpro-ingwersenk opened this issue Oct 4, 2024 · 0 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@senpro-ingwersenk
Copy link

What went wrong?

What happened:

I updated to OnCall 1.10.1, and then this happened:

2024-10-04 05:40:45 source=engine:app google_trace_id=none logger=root inbound latency=0.000737 status=200 method=GET path=/api/internal/v1/health/ user_agent=Go-http-client/2.0 content-length=0 slow=0
2024-10-04 05:40:45 source=engine:uwsgi status=200 method=GET path=/api/internal/v1/health/ latency=0.001727 google_trace_id=- protocol=HTTP/1.1 resp_size=264 req_body_size=0
2024-10-04 05:40:45 source=engine:app google_trace_id=none logger=apps.social_auth.middlewares SocialAuthAuthCanceledExceptionMiddleware.process_exception: Object of type OnCallError is not JSON serializable
2024-10-04 05:40:46 source=engine:app google_trace_id=none logger=django.request Internal Server Error: /api/internal/v1/plugin/v2/install
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/core/handlers/base.py", line 220, in _get_response
    response = response.render()
               ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/template/response.py", line 114, in render
    self.content = self.rendered_content
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rest_framework/response.py", line 74, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rest_framework/renderers.py", line 100, in render
    ret = json.dumps(
          ^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rest_framework/utils/json.py", line 25, in dumps
    return json.dumps(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rest_framework/utils/encoders.py", line 67, in default
    return super().default(obj)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type OnCallError is not JSON serializable
2024-10-04 05:40:46 source=engine:app google_trace_id=none logger=root inbound latency=0.149537 status=500 method=POST path=/api/internal/v1/plugin/v2/install user_agent=Go-http-client/1.1 content-length=4723 slow=0
2024-10-04 05:40:46 source=engine:uwsgi status=500 method=POST path=/api/internal/v1/plugin/v2/install latency=0.154425 google_trace_id=- protocol=HTTP/1.1 resp_size=428 req_body_size=4723

I... honestly have no idea what the error is. I mean, sure, there is an error, but I have no idea what or which one.

What did you expect to happen:

A working OnCall...

How do we reproduce it?

  1. Update from 1.9.20 -> 1.10.1
  2. Run migrations
  3. Start the updated instance.
  4. Grafana will likely want to have it's plugin updated and reconfigured too - so do that.
  5. Upon clicking "Connect", observe this error in the logs.

Grafana OnCall Version

1.10.1

Product Area

Other

Grafana OnCall Platform?

Kubernetes

User's Browser?

No response

Anything else to add?

No response

@senpro-ingwersenk senpro-ingwersenk added the bug Something isn't working label Oct 4, 2024
@mderynck mderynck self-assigned this Oct 7, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 7, 2024
# What this PR does
Fixes incorrect encoding when SyncException contains one of the
predefined dataclass errors in install_v2 endpoint.

## Which issue(s) this PR closes

Related to #5124 

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants