Skip to content

Fix AwaitMessageTrigger missing super().__init__() call#65934

Closed
david-parkk wants to merge 1 commit into
apache:mainfrom
david-parkk:fix/await-message-trigger-base-init
Closed

Fix AwaitMessageTrigger missing super().__init__() call#65934
david-parkk wants to merge 1 commit into
apache:mainfrom
david-parkk:fix/await-message-trigger-base-init

Conversation

@david-parkk
Copy link
Copy Markdown
Contributor

Summary

Fix AwaitMessageTrigger not calling super().__init__(), which caused an AttributeError
when the trigger was used as an AssetWatcher trigger.

Analysis

BaseTrigger.__init__() initialises self._task_instance = None, which is required for the
task_instance property to work correctly:

# airflow-core/src/airflow/triggers/base.py
class BaseTrigger:
    def __init__(self, **kwargs):
        self._task_instance = None  # ← must be set by super().__init__()
        ...

    @property
    def task_instance(self):
        return self._task_instance  # ← AttributeError if _task_instance never set

AwaitMessageTrigger.__init__() was missing the super().__init__() call, so
_task_instance was never initialised.

When the trigger is used as an AssetWatcher trigger, there is no associated task instance,
so _task_instance is never set. When the triggerer later accesses trigger.task_instance,
it raises:
image

AttributeError: 'AwaitMessageTrigger' object has no attribute '_task_instance'

This was confirmed by running KafkaMessageQueueTrigger (which delegates to
AwaitMessageTrigger) as an AssetWatcher trigger in a Breeze dev environment.

Changes

Added super().__init__() call to AwaitMessageTrigger.__init__().

Test

  • Added test_trigger_has_task_instance_attribute — verifies that _task_instance is
    properly initialised to None after instantiation, which is the condition required for
    AssetWatcher usage to work without AttributeError
  • All provider unit tests pass (uv run --project providers/apache/kafka pytest providers/apache/kafka/tests/unit/)
  • Static checks pass (prek run --from-ref main --stage pre-commit)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Generated-by: Claude following the guidelines

I'm happy to make any adjustments based on your feedback. Thank you to the maintainers for taking the time to review this contribution!

- add test to verify _task_instance
@david-parkk
Copy link
Copy Markdown
Contributor Author

@vincbeck Hi, thank you for reviewing and approving my PR!

I noticed that a similar change has already been merged by another member (#66302), so I’ll go ahead and close this PR.

I really appreciate your time. Looking forward to contributing more in the future!

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