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: remove reserved keywords from kwargs before passing it to requests #117

Merged
merged 4 commits into from
Jul 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ibm_cloud_sdk_core/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ def send(self, request: requests.Request, **kwargs) -> DetailedResponse:
# Check to see if the caller specified the 'stream' argument.
stream_response = kwargs.get('stream') or False

# Remove the keys we set manually, don't let the user to overwrite these.
reserved_keys = ['method', 'url', 'headers', 'params', 'cookies']
for key in reserved_keys:
kwargs.pop(key, None)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we want to just throw an error here or a message so the user knows their argument is being omitted.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think throwing an exception is not a good idea, since removing the headers will be quite common. I've added a warning log for now.


try:
response = self.http_client.request(**request,
cookies=self.jar,
Expand Down