Skip to content

Commit

Permalink
Merge pull request #2408 from onaio/fix-messaging-submission-issue
Browse files Browse the repository at this point in the history
Fix `IndexError` exception raised when comparing functions
  • Loading branch information
DavisRayM authored Apr 18, 2023
2 parents 405f28d + 67dc39d commit 4c7a300
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: CI
on:
- push
- pull_request
pull_request:
branches: ["main"]
push:
branches: ["main"]
concurrency:
group: ci-${{ github.workflow }}-${{ github.actor }}-${{ github.sha }}
cancel-in-progress: true
Expand Down Expand Up @@ -38,6 +40,7 @@ jobs:
- name: Install Pip requirements
run: |
pip install -U pip
pip install wheel
pip install -r requirements/base.pip
pip install -r requirements/dev.pip
pip install -r requirements/azure.pip
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ignore-patterns=

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))"

# Use multiple processes to speed up Pylint.
jobs=1
Expand Down
22 changes: 12 additions & 10 deletions onadata/apps/messaging/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
"""
Message serializers
"""

from __future__ import unicode_literals
from typing import Union

import json
import sys
from typing import Union

from actstream.actions import action_handler
from actstream.models import Action
from actstream.signals import action
from django.conf import settings
from django.contrib.auth import get_user_model
from django.http import HttpRequest
from django.utils.translation import gettext as _

from actstream.actions import action_handler
from actstream.models import Action
from actstream.signals import action
from rest_framework import exceptions, serializers

from onadata.apps.messaging.constants import MESSAGE, MESSAGE_VERBS
from onadata.apps.messaging.utils import TargetDoesNotExist, get_target

from onadata.libs.utils.common_tools import report_exception

User = get_user_model()

Expand Down Expand Up @@ -134,9 +133,12 @@ def create(self, validated_data):
instance = [
instance
for (receiver, instance) in results
if receiver == action_handler
].pop()
if receiver.__module__ == action_handler.__module__
and receiver.__name__ == action_handler.__name__
]
instance = instance[0]
except IndexError as exc:
report_exception("(debug) index error", exc, sys.exc_info())
# if you get here it means we have no instances
raise serializers.ValidationError(
"Message not created. Please retry."
Expand Down

0 comments on commit 4c7a300

Please sign in to comment.