Skip to content

Add Task SDK client contract tests - #77146

Merged
uranusjr merged 1 commit into
apache:mainfrom
astronomer:sdk-exec-api-tests
Nov 17, 2026
Merged

uranusjr merged 1 commit into
apache:mainfrom
astronomer:sdk-exec-api-tests

Conversation

@uranusjr

Copy link
Copy Markdown
Member

The Task SDK client is tested against a mocked server, and the Execution API routes against a hand-written client. Neither catches a client that assumes something the server doesn't do. #76825's first version had that bug, and only the Kubernetes e2e job caught it.

Add a task_sdk_client fixture that sends the real client's requests to this tree's routes in process, as the Dag processor and triggerer do. Use it to test the client methods that interpret a response: XCom reads, and the not-found mapping for Variables, Connections and the task and asset state stores. Document the convention in the Execution API AGENTS.md.

Two cases are left out on purpose:

  • Reading a mapped task's XCom with no map index. main returns null for it until Return a mapped task’s XComs when no map index is given #76825 is merged, and that PR adds the case here.
  • 401/403 to PERMISSION_DENIED. The in-process API overrides the access checks, so a test would only send the client a hand-written 403, which the mocked client tests already cover.

The Task SDK client is tested against a mocked server, and the
Execution API routes against a hand-written client. Neither catches
a client that assumes something the server doesn't do. apache#76825's
first version had that bug, and only the Kubernetes e2e job caught
it.

Add a task_sdk_client fixture that sends the real client's requests
to this tree's routes in process, as the Dag processor and triggerer
do. Use it to test the client methods that interpret a response:
XCom reads, and the not-found mapping for Variables, Connections and
the task and asset state stores. Document the convention in the
Execution API AGENTS.md.

Two cases are left out on purpose:

- Reading a mapped task's XCom with no map index. main returns null
  for it until apache#76825 is merged, and that PR adds the case here.
- 401/403 to PERMISSION_DENIED. The in-process API overrides the
  access checks, so a test would only send the client a hand-written
  403, which the mocked client tests already cover.

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There're some missing cases like task_instances.start or dag_runs.trigger but there's no harm to fill up the gap as follow-up, thanks.

@uranusjr
uranusjr merged commit ba4a811 into apache:main Nov 17, 2026
72 checks passed
@uranusjr
uranusjr deleted the sdk-exec-api-tests branch November 17, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:task-sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants