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

Fix HttpOperator pagination with str data #35782

Merged

Conversation

Joffreybvn
Copy link
Contributor

Hello,

When the HttpOperator is declared with a string in the data parameter, the pagination fails. Same when a string is returned for data by the pagination function. This is because the _merge_next_page_parameters was not handling the case where data is a string.

Thus, this PR:

  • Fix the string issue.
    → Now, during the merge, if any of the data parameter is a string, the new one simply override the initial one
  • Change the typing of the class to dict | str | None instead of Any
    → To be consistent with the HttpHook and the HttpTrigger
  • Get a more detailed docstring for the pagination

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

@Joffreybvn Joffreybvn force-pushed the fix/http-operator-paginate-with-string-data branch from 581363d to d904a72 Compare November 21, 2023 20:54
@potiuk
Copy link
Member

potiuk commented Nov 21, 2023

Nice.

@potiuk
Copy link
Member

potiuk commented Nov 21, 2023

NIT: should we also get a unit test with dicts passed as data and being merged? Maybe a parametrized test case where you can use strings/dicts ?

Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

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

Please add a test for this.

@Joffreybvn
Copy link
Contributor Author

Yes, will add a stronger test 👍

@potiuk potiuk merged commit 5588a95 into apache:main Nov 22, 2023
47 checks passed
ephraimbuddy pushed a commit that referenced this pull request Nov 23, 2023
* feat: Restrict `data` parameter typing

Follows the hook's typing

* feat: Implement `data` override when string

* feat: Improve docstring about merging and overriding behavior

* fix: Add correct typing for mypy

* feat: add test

* fix: remove unused imports

* fix: Update SimpleHttpOperator docstring

* feat: Correctly test parameters overriding
ephraimbuddy pushed a commit that referenced this pull request Nov 26, 2023
* feat: Restrict `data` parameter typing

Follows the hook's typing

* feat: Implement `data` override when string

* feat: Improve docstring about merging and overriding behavior

* fix: Add correct typing for mypy

* feat: add test

* fix: remove unused imports

* fix: Update SimpleHttpOperator docstring

* feat: Correctly test parameters overriding
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.

5 participants