Skip to content

AttributeError when creating a grafana_alerting Integration via the http api #5479

@Mewp

Description

@Mewp

What went wrong?

What happened:

  • Trying to create an itegration of type grafana_alerting via the http api returns 500. Logs are showing the following:
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 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rest_framework/viewsets.py", line 124, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/app/common/api_helpers/mixins.py", line 147, in handle_exception
    return super().handle_exception(exc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.12/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/rest_framework/mixins.py", line 19, in create
    self.perform_create(serializer)
  File "/usr/local/lib/python3.12/site-packages/rest_framework/mixins.py", line 24, in perform_create
    serializer.save()
  File "/usr/local/lib/python3.12/site-packages/rest_framework/serializers.py", line 208, in save
    self.instance = self.create(validated_data)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/app/apps/public_api/serializers/integrations.py", line 126, in create
    validated_data = self._add_service_label_if_needed(organization, validated_data)

What did you expect to happen:

  • The api would return a status code other than 500, ideally creating the integration.

How do we reproduce it?

  1. Make a POST request to /api/v1/integrations/ with body: {"type": "grafana_alerting"}
  2. Observe that it returns http 500
  3. Check logs

Grafana OnCall Version

1.15

Product Area

API

Grafana OnCall Platform?

Kubernetes

User's Browser?

No response

Anything else to add?

Indeed, the name _add_service_label_if_needed doesn't exist anywhere else in the codebase. It was added in the last commit that was modifying the file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions