fix(webhooks): forward overrides from webhooks.list - #483
Open
toolshedlabs-hash wants to merge 1 commit into
Open
fix(webhooks): forward overrides from webhooks.list#483toolshedlabs-hash wants to merge 1 commit into
toolshedlabs-hash wants to merge 1 commit into
Conversation
Webhooks.list accepted overrides and documented it, then called super().list() without it, so a per request api_key, api_uri, timeout or headers had no effect on that one call. It is the only method in nylas/resources/ that accepts overrides and does not pass it on. Adds a regression test and a CHANGELOG entry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
License
I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.
The defect
client.webhooks.list(overrides=...)accepts the argument and documents it, then calls thebase method without it. The request goes out with the client's own settings, so a per
request
api_key,api_uri,timeoutorheadershas no effect on that one call.ListableApiResource.listacceptsoverridesand forwards it to_execute, so nothingfurther down is putting it back.
Reproduction
Clean venv,
nylas==6.17.0from PyPI, Python 3.14.0. One client, one loopback server thatrecords the
Authorizationheader of every request.webhooks.list(overrides=OVERRIDES)Bearer CLIENT-DEFAULT-KEYwebhooks.find("wh_1", overrides=OVERRIDES)Bearer PER-REQUEST-OVERRIDE-KEYwebhooks.ip_addresses(overrides=OVERRIDES)Bearer PER-REQUEST-OVERRIDE-KEYgrants.list(overrides=OVERRIDES)Bearer PER-REQUEST-OVERRIDE-KEYThe last row is the control worth having. It is a
liston a different resource, so theshape forwards overrides fine and the problem is this one method.
How wide it is
An AST pass over
nylas/resources/finds 141 methods that acceptoverrides, and checkswhether each one reads the name anywhere in its body. Exactly one never does, and this is
it. The check counts positional and renamed forwarding as correct, which matters, because
auth.pypasses it positionally asself._get_token(request_body, overrides)anddomains.pypasses it asoverrides=mergedafter_merge_signer_headersruns.The change
Plus a regression test in
tests/resources/test_webhooks.pythat asserts_executeiscalled with the overrides, and a CHANGELOG bullet. The test fails on main and passes with
the change.
pytestis 475 passed, 3 deselected.pylint nylas/resources/webhooks.pyis 10.00.The CHANGELOG bullet went under a new
Unreleasedheading because there is not one at themoment. Happy to drop that hunk if you would rather add it at release time.