Skip to content

airflowctl: initialize extra for create assets event - #55744

Merged
bugraoz93 merged 4 commits into
apache:mainfrom
sidshas03:fix/airflowctl-create-event
Sep 18, 2025
Merged

bugraoz93 merged 4 commits into
apache:mainfrom
sidshas03:fix/airflowctl-create-event

Conversation

@sidshas03

@sidshas03 sidshas03 commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor

Align airflowctl with the FastAPI contract for POST /assets/events.

What

  • Use absolute path "/assets/events" in AssetsOperations.create_event (was "assets/events").
  • Add a small client test asserting route + payload:
    • airflow-ctl/tests/test_create_event_client.py
  • Request/response match the datamodel (CreateAssetEventsBody → AssetEventResponse).

Why

  • Avoid routing issues from relative paths.
  • Keep airflowctl in sync with API + models (pairs with the POST /assets work).

Related: #55697
Companion: #55702

Verify

python -m pytest -q airflow-ctl/tests -k create_event

@sidshas03

sidshas03 commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor Author

@bugraoz93 @jason810496

Recent Commits on fix/airflowctl-create-event branch:
dea192bf78 - airflowctl: use absolute "/assets" for assets create (consistency)
056eed423b - api: document 422 for POST /assets
d0d75edc25 - tests(api): move POST /assets tests into test_assets.py to match assets.py
8e48c8d3b2 - airflowctl: align create_event with API; absolute '/assets/events' and add client unit test
24ec0bc - tests(api): POST /assets happy path, duplicate(409), validation(400/422), and auth (401/403)

@bugraoz93 bugraoz93 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks a lot for the fix! I think we can separate and merge the fix quicker :)

@sidshas03
sidshas03 force-pushed the fix/airflowctl-create-event branch from dea192b to cbd3055 Compare September 17, 2025 18:27
@sidshas03

sidshas03 commented Sep 17, 2025 •

Copy link
Copy Markdown
Contributor Author

Update: I’ve scoped this PR to the single-line client fix.
Latest commit: cbd3055 — fix(airflowctl): use absolute "/assets/events" path for create_event. This changes only airflow-ctl/src/airflowctl/api/operations.py from "assets/events" → "/assets/events" to match the FastAPI route. ([GitHub][1])
Addresses feedback: This implements @bugraoz93’s suggestion to keep just the path change and drop the extra client test so this can merge quickly; I’ve resolved those threads.
Next: Please take another look and let me know if anything else is needed. If you’d like, I can follow up with an integration test PR for airflowctl create_event.

@bugraoz93 bugraoz93 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the update! That should be enough. No need to include tests, we already have tests here

. What is happening for the bug couldn't be caught with the unit tests. We will implement integration tests in another issue soon. That's why for the test part, we don't need to follow up on unit test side

@bugraoz93 bugraoz93 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(airflow) bugra@dev:~/PycharmProjects/airflow$ airflowctl assets create-event --asset-id=1
2025-09-17 22:52:40 [warning  ] Server error                   [airflowctl.api.client] extra={'detail': [{'type': 'dict_type', 'loc': ['body', 'extra'], 'msg': 'Input should be a valid dictionary', 'input': None}]}
Server response error: Client error message: {'detail': [{'type': 'dict_type', 'loc': ['body', 'extra'], 'msg': 'Input should be a valid dictionary', 'input': None}]}
Client error,  Please check the command and its parameters. If you need help, run the command with --help.

I don't think this resolves the bug. I have tested locally, but I still get the above error. I think that part can stay without /. If you check the entire file, config is the only one that has the / at the beginning. I think that doesn't follow the convention, even though it is working (I believe it is handled by the client). So I think it really doesn't change anything to have the / there
You can test your changes by running Breeze and the API server. You can also use airflowctl with uv sync and test it locally.

@sidshas03
sidshas03 force-pushed the fix/airflowctl-create-event branch from cbd3055 to c3555b0 Compare September 17, 2025 21:14
sidshas03 and others added 4 commits September 18, 2025 19:38
- Add guard in create_event method to ensure extra is never null
- Change path from 'assets/events' to '/assets/events' for consistency
- Prevents DB/UI issues when extra field is None
@bugraoz93
bugraoz93 force-pushed the fix/airflowctl-create-event branch from f979927 to 65b9c54 Compare September 18, 2025 17:38
@bugraoz93

Copy link
Copy Markdown
Contributor

We need to merge this fix, so I added a couple of changes there. Thanks for the PR! I will merge once it is green

@sidshas03

Copy link
Copy Markdown
Contributor Author

We need to merge this fix, so I added a couple of changes there. Thanks for the PR! I will merge once it is green

If any job turns red, I’ll take a look and fix only what the failing log shows.

@bugraoz93 bugraoz93 changed the title airflowctl: align create_event with API/datamodel (+ client test) airflowctl: initialize extra for create assets event Sep 18, 2025
@bugraoz93
bugraoz93 merged commit eaa0331 into apache:main Sep 18, 2025
@boring-cyborg

boring-cyborg Bot commented Sep 18, 2025

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

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

Labels

area:airflow-ctl area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants