Wait for config API to avoid NaN passed to offset. #44989
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Whenever a page is loaded the offset and limit values are passed to the API from pagination object.
limitis fetched fromconfigAPI throughpage_sizein airflow.cfg. Aspagination.pageSizeis undefinedoffsetwhich ispagination.pageIndex * pagination.pageSizebecomes NaN and passed to the API causing backend to return 422 if the API call for a resource is made beforeconfigfinishes. Once config finishes the offset value is calculated properly and then passed to API resulting in two API calls with 1 invalid returning 422 and then again passing with valid offset value to fetch the correct response. Useenabledoption to not make call if theoffsetisNaN. Another option would be default value forpagination.pageSizebut that would result in 2 API calls with default value and later the value fromconfigAPI call.Another issue is that for running dagruns and running/deferred task instances the
end_dateis not present causingNaNto be displayed in UI in dagrun duration, task instance duration, etc. Use current time if end_date is not present like the legacy UI.To reproduce :
http://localhost:8000/public/dags?offset=NaN&only_active=true&order_by=-last_run_start_date
http://localhost:8000/ui/dags/recent_dag_runs?dag_runs_limit=14&offset=NaN&only_active=true