Skip to content

Conversation

@anshuksi282-ksolves
Copy link
Contributor

closes: #54800

Description

This PR restores and enhances the ability to pre-populate the Trigger DAG and Backfill forms via URL query parameters in the Airflow 3.0 UI. This feature existed in Airflow 2.x and is useful for sharing pre-configured run links.

Key Changes:

  1. URL Param Parsing:

    • Implemented using the useSearchParams hook (replacing manual parsing logic from stale PRs).
    • Added a utility getTriggerConf to handle both JSON strings (?conf={"a":1}) and Key-Value pairs (?a=1).
  2. Form Updates:

    • Trigger Form: Supports run_id, logical_date, note, and conf.
    • Backfill Form: Supports from_date, to_date, max_active_runs, reprocess_behavior, and run_backwards.
    • Config Form: Automatically expands the "Advanced Options" accordion if configuration data is present in the URL.
  3. Code Quality:

    • Optimized RunBackfillForm.tsx logic to keep the file size strictly under the 250-line linting limit.
    • Ensured consistent naming conventions for backfill parameters (from_date / to_date) to match the API and UI components.
  4. Documentation:

    • Updated docs/core-concepts/params.rst to document the supported URL parameters and examples.

How to reproduce / Test

You can test this by running the UI and navigating to any DAG (e.g., tutorial) using the following URLs:

1. Trigger Single Run (JSON Config):
The modal should open, fields should be filled, and the JSON editor should show the config.
http://localhost:8080/dags/tutorial/trigger/single?run_id=test_run_01&note=Testing_Note&conf={"environment":"dev","debug":true}

2. Trigger Single Run (Key-Value Config):
The "Advanced Options" should open and show {"foo": "bar"}.
http://localhost:8080/dags/tutorial/trigger/single?foo=bar&retry=3

3. Backfill Form:
The Backfill form should open with dates, max runs, and the "Run Backwards" checkbox pre-selected.
http://localhost:8080/dags/tutorial/trigger/backfill?from_date=2024-01-01T00:00:00&to_date=2024-01-05T00:00:00&max_active_runs=5&run_backwards=true


^ 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.

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

PR Looks clear and good for me.

I tried but the trigger form was not opening. Don't know if I mis-understood but I needed to click the "trigger" button to open the form pre-populated. Otherwise working fine. I'd expected it is oepning pre-populated when calling with a prepared/pre-filled URL.


The ability to update params while triggering a Dag depends on the flag ``core.dag_run_conf_overrides_params``.
Setting this config to ``False`` will effectively turn your default params into constants.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you maybe add a chapter header?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @jscheffl Agreed. I have added a new section header "Pre-populating Trigger Form via URL" to clearly separate this topic in the documentation.


- ``run_backwards`` - if set to true, the backfill is scheduled in reverse order. Defaults to ``false``.

The trigger form now supports two different ways of providing ``conf`` values. The available input methods are summarized in the table below:
Copy link
Contributor

Choose a reason for hiding this comment

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

The term "now" is a bit relative... especially if you might read the same text in 10 years if the feature still exists.

Suggested change
The trigger form now supports two different ways of providing ``conf`` values. The available input methods are summarized in the table below:
The trigger form supports two different ways of providing ``conf`` values. The available input methods are summarized in the table below:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The term "now" is a bit relative... especially if you might read the same text in 10 years if the feature still exists.

Good point. I have updated the text to remove the word "now" as suggested.

@anshuksi282-ksolves
Copy link
Contributor Author

PR Looks clear and good for me.

I tried but the trigger form was not opening. Don't know if I mis-understood but I needed to click the "trigger" button to open the form pre-populated. Otherwise working fine. I'd expected it is oepning pre-populated when calling with a prepared/pre-filled URL.

Hi @jscheffl Thanks for catching that! You are correct, I missed wiring the URL state to the modal visibility logic in the initial commit.

I have pushed a fix in the latest commit (Overview.tsx) where I check for the mode parameter in the URL. Now, if the URL contains /trigger/single or /trigger/backfill, the modal will open automatically with the pre-populated values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers. kind:documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger form can be called via URL with fields pre-populated.

2 participants