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

Add Warning for Incorrect Keyword Arguments in POST Requests (e.g., 'header' instead of 'headers') #6792

Closed
jsilverman26 opened this issue Aug 23, 2024 · 1 comment
Labels
actions/autoclose-feat Used for automation to auto-close an issue Feature Request

Comments

@jsilverman26
Copy link

Summary:

When making a POST request using the requests library, passing an incorrect keyword argument (e.g., header instead of headers) does not trigger any error or warning. This can lead to unintended behavior, as the request proceeds without the intended headers being applied.

Problem:

The requests library currently does not validate keyword arguments for correctness. If a user accidentally passes a misspelled argument like header instead of headers, the request will still execute, but the headers will not be set as expected. This lack of validation makes it easy to overlook such errors, leading to potential issues that can be difficult to debug.

Proposed Solution:

Introduce a warning mechanism that alerts the user when an unrecognized keyword argument is passed. This could be implemented as a simple check within the requests functions to identify commonly mistaken keywords like header and issue a warning, helping developers catch such errors early.

Benefit:

Adding this feature would improve the developer experience by reducing the likelihood of subtle bugs caused by incorrect keyword arguments. It would also make the requests library more user-friendly by providing immediate feedback when a common mistake is made.

Additional Context:

This issue was observed during development when a request was made with header instead of headers, causing the request to proceed without applying the necessary headers. A warning in such cases would have saved considerable debugging time.

image

Thank you for considering this enhancement!

@jsilverman26 jsilverman26 added actions/autoclose-feat Used for automation to auto-close an issue Feature Request labels Aug 23, 2024
Copy link

As described in the template, Requests is not accepting feature requests

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2024
@github-actions github-actions bot locked as off-topic and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
actions/autoclose-feat Used for automation to auto-close an issue Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant