fix(google_chat): report why a send failed - #6748
Open
purisev wants to merge 2 commits into
Open
Conversation
__send_message returns only on 200 and raises otherwise, so the `response.status_code != OK` check after the call could never fire and the ProviderException under it, the one carrying response.text, was unreachable. A rejected message surfaced as "Failed to notify message after 3 attempts" with the reason discarded, so a malformed payload and a revoked key looked the same from the workflow. That check is gone and the last error, response body included, now travels with the exception. It is redacted on the way: Google quotes the request URL in some of its errors and that URL carries the key and token credentials in its query string. Connection errors were already being logged with the URL intact and go through the same redaction now. The retry loop had no coverage at all, which is what hid this. The tests cover one attempt on success, a transient failure retried and then succeeding, three attempts before giving up, the body reaching the caller, redaction of both a response body and a connection error, the content type header, and unrelated workflow parameters being ignored. Signed-off-by: Iurii Purisev <92510590+purisev@users.noreply.github.com>
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.
Problem
See #6746.
__send_messageinsideGoogleChatProvider._notifyreturns only on 200and raises otherwise, so the
response.status_code != http.HTTPStatus.OKcheckafter the call can never fire and the
ProviderExceptionunder it, the onecarrying
response.text, is unreachable. A rejected message surfaces asFailed to notify message after 3 attemptswith Google's explanation discarded,so a malformed payload and a revoked key look the same from the workflow.
Fix
plus response body, or the connection error — now travels with the exception.
its errors, and a Chat webhook URL carries
keyandtokenin its querystring. The connection errors already being logged went out with the URL
intact; they go through the same redaction now.
Behaviour on success is unchanged.
Tests
The retry loop had no coverage at all, which is what hid this.
tests/providers/google_chat_provider/test_google_chat_provider.pyis new andcovers one attempt on success, a transient failure retried and then succeeding,
three attempts before giving up, the body reaching the caller, redaction of both
a response body and a connection error, the content type header, and unrelated
workflow parameters being ignored. 8 tests, all passing.
Fixes #6746