Skip to content

Fix dag.test() dropping defer-time kwargs when trigger yields an event#69942

Open
seanghaeli wants to merge 3 commits into
apache:mainfrom
aws-mwaa:fix/neptune-analytics-accessdenied
Open

Fix dag.test() dropping defer-time kwargs when trigger yields an event#69942
seanghaeli wants to merge 3 commits into
apache:mainfrom
aws-mwaa:fix/neptune-analytics-accessdenied

Conversation

@seanghaeli

@seanghaeli seanghaeli commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

In dag.test(), a deferred task loses the kwargs it passed to defer() when its trigger fires; they get discarded on resume instead of kept. This adds the trigger event onto those kwargs rather than discarding them, so the resume method still receives them.

This makes it match how the triggerer already resumes deferred tasks in normal execution:

next_kwargs["event"] = event.payload

Fixes the neptune_analytics deferrable test.

When DAG.test() runs a deferred task's trigger inline and the trigger
yields an event, the kwargs passed at defer() time were discarded and
replaced with only {"event": ...}. The resume method then ran with its
default argument values.

This broke example_neptune_analytics on the deferrable path:
NeptuneCreatePrivateGraphEndpointOperator defers with
kwargs={"vpc_id": self.vpc_id} and resumes into
execute_complete(..., vpc_id=""). The lost vpc_id fell back to "" and
was pushed to XCom; the downstream delete_endpoint task built a malformed
request URI (/graphs/<id>/endpoints/) and the service rejected it with
AccessDeniedException: Unable to determine service/operation name to be
authorized.

Merge the event into the deferral's next_kwargs instead of replacing
them, mirroring the production resume path in airflow.models.trigger.
Add a regression test.
@seanghaeli
seanghaeli force-pushed the fix/neptune-analytics-accessdenied branch from 8c75edc to deafa2e Compare July 16, 2026 16:31
@seanghaeli seanghaeli closed this Jul 16, 2026
@seanghaeli seanghaeli reopened this Jul 16, 2026
@seanghaeli
seanghaeli force-pushed the fix/neptune-analytics-accessdenied branch from e1a2b80 to 9e87b69 Compare July 17, 2026 01:07
@seanghaeli
seanghaeli force-pushed the fix/neptune-analytics-accessdenied branch from 9e87b69 to 2cae70e Compare July 17, 2026 01:11
@seanghaeli
seanghaeli marked this pull request as ready for review July 17, 2026 01:16
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.

1 participant