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

Request retry failed with empty body #2510

Closed
kyzhangZao opened this issue May 22, 2024 · 3 comments
Closed

Request retry failed with empty body #2510

kyzhangZao opened this issue May 22, 2024 · 3 comments
Labels
Needs: Attention 👋 status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience type:question An issue that's a question

Comments

@kyzhangZao
Copy link

kyzhangZao commented May 22, 2024

Describe the bug

Hi SDK team,

Our service is on sdk version 5.31.0, and this is the latest capable version with our framework.
An unexpected behavior we started to get after switch to use this sdk version (from sdk version 3.19) is that retries handled by Polly ExecuteAsync is sending empty request body/some of the request properties are missing, which lead to the retry failure. The request body contains all expected properties during the first attempt. Issues are only seen in retries.

Expected behavior

Object created outside of the retry block should be picked up correctly by the Polly handler.

How to reproduce

code snippet

var secret = 'some secret';
var subscription = new Subscription {
    Resource = $"{Some resource name}",
    ClientState = secret.ToString(),
    ExpirationDateTime = DateTime.UtcNow.AddHours(some time interval)
};
var createdSubscription = await retryPolicy.ExecuteAsync(
    context => graphServiceClient.Subscriptions.PostAsync(subscription),
    traceableData.AsPollyContext()).ConfigureAwait(false);

SDK Version

5.31.0

Latest version known to work for scenario above?

No response

Known Workarounds

Our workaround at this moment is to recreate the object within the retry block with all the required properties. But we would like to understand the reason why the object is not being picked up correctly if it's being created outside of the retry block.

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

We're a 1p app, feel free to reach out on Teams
@kyzhangZao kyzhangZao added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels May 22, 2024
@andrueastman
Copy link
Member

Thanks for raising this @kyzhangZao

I believe this is caused by the functionality of the backing store that keeps track of data that is serialized out.
https://learn.microsoft.com/en-us/openapi/kiota/backing-store.

To resolve this, you would probably need to recreate the object within the retry block. Or add this line in the block before sending out the retry.
subscription.BackingStore.IntitializationCompleted = false;

Out of curiosity, is there a specific reason that you do not use the inbuilt retry mechanism available in the SDK?
https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/upgrade-to-v5.md#per-request-options

@andrueastman andrueastman added type:question An issue that's a question Needs: Author Feedback status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels May 23, 2024
@kyzhangZao
Copy link
Author

kyzhangZao commented May 23, 2024

Hi @andrueastman ,

Thanks a lot for the above info.

Regarding to retry,
Our retry mechanism predates the use of the SDK (some historical reason) and we retry on specific error messages. And our retry mechanisms applies to all the requests from the graphclient, we don't have use cases that we set special rules for specific requests.

@andrueastman
Copy link
Member

Thanks for the extra info @kyzhangZao

We'll close this one for now. Feel free to re-open/create new issue incase of anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention 👋 status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience type:question An issue that's a question
Projects
None yet
Development

No branches or pull requests

2 participants