-
Notifications
You must be signed in to change notification settings - Fork 252
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
Response content in custom RetryHandler remains compressed #2545
Comments
Thanks for raising this @MichalLechowski The reading of content isn't expected by the default If you wish to get the uncompressed content, you could place the custom handler infront of the Out of curiosity, is there a specific reason you wish to read the response body in the handler? Ideally, the status code/headers should give enough info if you need retry.. |
Actually there is an underneath issue which I overcome by reading an actual error rather than just status code. When I create multiple MS Teams channels, something like:
I occasionally get BadRequest response, even though the resource was successfully created.
But when I take a look at MS Teams, that channel got created successfully, so it's a misleading BadRequest and I should stop retrying to create already existing channel. So I wanted to know what is inside the error and it turned out that after decompression and deserialization, the error is "Channel name already exists", which means it is retrying that request even though the channel got successfully created. Which proved my suspicion. The problem is I didn't get successful code, I got 429, then 400, which resulted in channel created. I have no idea why it behaves this way. if you have any idea what might be wrong, please let me know. RetryHandler logic for it:
|
Apologies for the delayed response @MichalLechowski Is there a specific reason not do something like this? Using pattern matching you can filter out the error scenario as below. try
{
await graphClient.Teams[teamId.ToString()]
.Channels
.PostAsync(new Channel() { DisplayName = channel });
}
catch (ODataError error) when (error.Message.Equals("Channel name already existed, please use other name",
StringComparison.OrdinalIgnoreCase))
{
//Do nothing as the channel was created in a back off
}
catch (ODataError error)
{
await Console.Error.WriteLineAsync(error.Message);
} Also, would you be willing to submit feedback on the API behavior returning 429 on successful call at https://aka.ms/graphfeedback? |
I submitted feedback as requested. As to your suggestion, I don't wanna spread retry logic into multiple spaces, it's not graph client responsibility to take care of it, it's retry handler's. Not to mention sometimes BadRequest response requires retry e.g. in case of "Folder location for this channel is not ready yet, please try again later". I suppose the real solution is to return created status when channel got created instead of errors. I am leaving the decompression and deserialization for now, we don't care if it takes extra seconds for a background job to finish processing, but it for sure should not behave like this. If there are any other suggestions or debugging to do, let me know, I'm willing to try anything. |
Thanks for getting back @MichalLechowski As you correctly put it the best thing would be for the correct status to be returned (Thanks for filing the feedback). To avoid having the compression logic in your custom handler, all you would need to do is handlers.Insert(0, customRetryHandler); instead of handlers[retryHandlerIndex] = customRetryHandler; So that the default As there's no further action on the SDK side, we'll look to closing this issue. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
Describe the bug
When trying to read response content within custom RetryHandler, it remains compressed and needs to be manually decompressed. Default compression handler is called after it and it gets decompressed too late.
Expected behavior
Content should be already decompressed in custom RetryHandler
How to reproduce
Graph client initialization:
Custom RetryHandler where the problem is:
Content here is compressed and it requires manual decompression like below, which I think should not be necessary?
SDK Version
5.53.0
Latest version known to work for scenario above?
No response
Known Workarounds
Manual decompression
Debug output
Click to expand log
```The text was updated successfully, but these errors were encountered: