Skip to content
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

Do not use core Airflow Flask related resources in FAB provider (tests of www) #45472

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vincbeck
Copy link
Contributor

@vincbeck vincbeck commented Jan 7, 2025

Follow-up of #45441.

In #45441 I forgot to apply the changes in tests as well. This PR solves that.


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

@vincbeck vincbeck requested a review from jedcunningham January 7, 2025 19:21
@vincbeck vincbeck force-pushed the vincbeck/www-tests branch 4 times, most recently from 2913b83 to 8852b69 Compare January 8, 2025 15:31
app.register_error_handler(ProblemException, common_error_handler)


def init_api_connexion(app: Flask) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

We are probably at a point we can rip out the old api, to be honest - I think aip-84 is far enough along.

If we want to keep it for now, that's fine, however we might want to leave a breadcrumb that this needs to go before AF3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Though, removing it make some tests fail. Some tests in FAB provider are using Rest API endpoints (e.g. /api/v1/pools in providers/tests/fab/auth_manager/api_endpoints/test_auth.py). So we need to update these tests as well. I prefer doing it in a separate PR because I think this one is big enough already.

@vincbeck vincbeck force-pushed the vincbeck/www-tests branch 2 times, most recently from f478c70 to f5b453c Compare January 8, 2025 19:56
@vincbeck vincbeck force-pushed the vincbeck/www-tests branch from f5b453c to bfc0cad Compare January 8, 2025 21:19
@vincbeck vincbeck requested a review from Copilot January 8, 2025 23:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 14 out of 29 changed files in this pull request and generated 2 comments.

Files not reviewed (15)
  • providers/src/airflow/providers/fab/www/templates/airflow/no_roles_permissions.html: Language not supported
  • providers/tests/fab/auth_manager/api_endpoints/test_dag_run_endpoint.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_dag_source_endpoint.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_asset_endpoint.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_variable_endpoint.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_import_error_endpoint.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_event_log_endpoint.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_dag_warning_endpoint.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_dag_endpoint.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_xcom_endpoint.py: Evaluated as low risk
  • providers/src/airflow/providers/fab/www/app.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api/auth/backend/test_basic_auth.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api/auth/backend/test_session.py: Evaluated as low risk
  • providers/src/airflow/providers/fab/auth_manager/security_manager/override.py: Evaluated as low risk
  • providers/tests/fab/auth_manager/api_endpoints/test_auth.py: Evaluated as low risk
Comments suppressed due to low confidence (3)

providers/src/airflow/providers/fab/www/extensions/init_views.py:135

  • The method_not_allowed function should be imported at the top of the file for clarity and to avoid potential issues with circular imports.
from airflow.providers.fab.www.views import method_not_allowed

providers/src/airflow/providers/fab/www/extensions/init_views.py:111

  • [nitpick] Encapsulate the base_paths list within a class to avoid potential side effects and make the code more maintainable.
base_paths: list[str] = []

providers/src/airflow/providers/fab/www/views.py:53

  • [nitpick] The error message is too generic. It should be updated to 'Method Not Allowed: The requested method is not allowed for the requested URL.'
error_message="Received an invalid request."

if allow_origins == "*":
response.headers["Access-Control-Allow-Origin"] = "*"
elif allow_origins:
allowed_origins = allow_origins.split(" ")
Copy link
Preview

Copilot AI Jan 8, 2025

Choose a reason for hiding this comment

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

The allow_origins variable should be split by commas instead of spaces to handle multiple origins more accurately.

Suggested change
allowed_origins = allow_origins.split(" ")
allowed_origins = allow_origins.split(",")

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
# here on the application level
return common_error_handler(ex)
else:
from airflow.providers.fab.www.views import not_found
Copy link
Preview

Copilot AI Jan 8, 2025

Choose a reason for hiding this comment

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

The not_found function should be imported at the top of the file for clarity and to avoid potential issues with circular imports.

Suggested change
from airflow.providers.fab.www.views import not_found
return not_found(ex)

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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.

2 participants