Skip to content

[Don't merge] Implement Human-in-the-Loop (HITL) shared links functionality #53057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from

Conversation

sunank200
Copy link
Collaborator

This PR implements Human-in-the-Loop shared links functionality as described in AIP-90. It enables shareable URLs for HITL tasks, allowing users to interact with HITL operators via direct links.

Key Changes

  • Configurable HITL Shared Links:
    • Added new Airflow config options to enable/disable HITL shared links, set secret keys, and configure link expiration.
  • Shared Link Utilities:
    • Utility module for generating and verifying signed HITL URLs with HMAC signatures and expiration.
  • API Endpoints:
    • Endpoints for generating shared links, retrieving HITL responses via shared links, and performing actions via shared links.
    • Redirect endpoint to Airflow UI for HITL tasks.
  • Security:
    • All shared links are signed and time-limited to prevent CSRF and unauthorized access.
    • Feature is opt-in and must be enabled in configuration.

closes:#52202

depends on: 52868


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:ConfigTemplates area:db-migrations PRs with DB migration area:Triggerer area:UI Related to UI/UX. For Frontend Developers. kind:documentation labels Jul 8, 2025
@sunank200 sunank200 marked this pull request as draft July 8, 2025 22:30
@Lee-W Lee-W self-requested a review July 9, 2025 02:38
@Lee-W Lee-W moved this to In progress in AIP-90 - Human in the loop Jul 9, 2025
@Lee-W
Copy link
Member

Lee-W commented Jul 11, 2025

Hey @sunank200 , the main AIP-90 branch has been merged. Would be great if you could rebase from the main branch again 🙂 Drop the the first 19 commits directly and then cherry-pick might make everything easier.

Also, discussed with @guan404ming , the frontend can't get ti_id directly. Thus, we change the endpoints to the following.

  1. GET /api/v2/hitl-details/{dag_id}/{dag_run_id}/{task_id}: Get a HITLDetail for a specific task instance
  2. GET /api/v2/hitl-details/{dag_id}/{dag_run_id}/{task_id}/{map_index}: Get a HITLDetail for a specific mapped task instance
  3. PATCH /api/v2/hitl-details/{dag_id}/{dag_run_id}/{task_id}: write the response content part back to an existing HITLDetail for a specific task instance
  4. PATCH /api/v2/hitl-details/{dag_id}/{dag_run_id}/{task_id}/{map_index}: write the response content part back to an existing HITLDetail for a specific mapped task instance

We'll need your help to change the share link endpoint to something like

  • /api/v2/hitl-details-share-link/{dag_id}/{dag_run_id}/{task_id}
  • /api/v2/hitl-details-share-link/{dag_id}/{dag_run_id}/{task_id}/{map_index}

Add a /shared at the end of the endpoint won't work due to {map_index}. I thought of /api/v2/hitl-details/dagId/{dag_id}/dagRunId/{dag_run_id}/taskId/{task_id}/mapIndex/{map_index}, which makes appending works. However, I decided not to do it as it makes the URL too lengthy

@sunank200
Copy link
Collaborator Author

Hey @sunank200 , the main AIP-90 branch has been merged. Would be great if you could rebase from the main branch again 🙂 Drop the the first 19 commits directly and then cherry-pick might make everything easier.

Also, discussed with @guan404ming , the frontend can't get ti_id directly. Thus, we change the endpoints to the following.

  1. GET /api/v2/hitl-details/{dag_id}/{dag_run_id}/{task_id}: Get a HITLDetail for a specific task instance
  2. GET /api/v2/hitl-details/{dag_id}/{dag_run_id}/{task_id}/{map_index}: Get a HITLDetail for a specific mapped task instance
  3. PATCH /api/v2/hitl-details/{dag_id}/{dag_run_id}/{task_id}: write the response content part back to an existing HITLDetail for a specific task instance
  4. PATCH /api/v2/hitl-details/{dag_id}/{dag_run_id}/{task_id}/{map_index}: write the response content part back to an existing HITLDetail for a specific mapped task instance

We'll need your help to change the share link endpoint to something like

  • /api/v2/hitl-details-share-link/{dag_id}/{dag_run_id}/{task_id}
  • /api/v2/hitl-details-share-link/{dag_id}/{dag_run_id}/{task_id}/{map_index}

Add a /shared at the end of the endpoint won't work due to {map_index}. I thought of /api/v2/hitl-details/dagId/{dag_id}/dagRunId/{dag_run_id}/taskId/{task_id}/mapIndex/{map_index}, which makes appending works. However, I decided not to do it as it makes the URL too lengthy

@Lee-W I have covered all of these in #53189

Closing this PR.

@sunank200 sunank200 closed this Jul 11, 2025
@github-project-automation github-project-automation bot moved this from In progress to Done in AIP-90 - Human in the loop Jul 11, 2025
@sunank200 sunank200 deleted the human-shared-links branch July 14, 2025 06:13
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:ConfigTemplates area:db-migrations PRs with DB migration area:Triggerer area:UI Related to UI/UX. For Frontend Developers. kind:documentation
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants