Skip to content

ARQ Integration: Cron Jobs (cron_jobs) Handling Error #4427

Closed
@ninoseki

Description

@ninoseki

How do you use Sentry?

Self-hosted/on-premise

Version

2.29.1

Steps to Reproduce

ARQ's worker (WorkerSettings) can have None as cron_jobs (ref. https://github.com/python-arq/arq/blob/main/arq/typing.py#L41)

But this section doesn't take it into consideration: https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/arq.py#L215-L218.

Thus the following code raises an error:

import sentry_sdk
from arq import func
from arq.connections import RedisSettings
from sentry_sdk.integrations.arq import ArqIntegration

REDIS_SETTINGS = RedisSettings()


sentry_sdk.init(
    "...",
    integrations=[ArqIntegration()],
)


async def task(_):
    return 1 + 1


class WorkerSettings:
    functions = [func(task)]  # type: ignore
    cron_jobs = None
...
  File "/path/to/.venv/lib/python3.11/site-packages/sentry_sdk/integrations/arq.py", line 218, in _sentry_create_worker
    settings_cls.cron_jobs = [
                             ^
TypeError: 'NoneType' object is not iterable
Sentry is attempting to send 2 pending events
Waiting up to 2 seconds
Press Ctrl-C to quit

Expected Result

ARQ integartion can handle cron_jobs = None without the above error.

Actual Result

Please check "Steps to reproduce" section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions