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

Consider not throwing for completed but unsuccessful long-running operations #21312

Closed
pakrym opened this issue May 24, 2021 · 11 comments
Closed
Assignees
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Milestone

Comments

@pakrym
Copy link
Contributor

pakrym commented May 24, 2021

Azure/autorest.csharp#464

From @heaths :

FWIW, Krzysztof asked that we not throw during UpdateStatus for supported status codes (e.g. 200, 202, 404) and similar calls - only when getting a value (similar to Nullable). I believe Pavel was part of this discussion as well. As a result - with oversight from Krzysztof, the Key Vault pseudo-LROs are what Krzysztof wanted: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/keyvault/Azure.Security.KeyVault.Keys/src/DeleteKeyOperation.cs

@pakrym pakrym added the Client This issue points to a problem in the data-plane of the library. label May 24, 2021
@pakrym
Copy link
Contributor Author

pakrym commented May 25, 2021

@kinelski pointed out that this would be against our current guidelines.

cc @christothes who worked on Azure/azure-sdk#2003

@heaths
Copy link
Member

heaths commented May 25, 2021

When I implemented the LROs for Key Vault (real and pseudo-LROs) back in 2019, @KrzysztofCwalina recommended we throw from Value much like Nullable<T>.Value. If recommendations have changed, please ignore my comment.

@pakrym
Copy link
Contributor Author

pakrym commented May 25, 2021

No, I think you were right. The Value should throw but I don't think the UpdateStatus should.

@annelo-msft
Copy link
Member

annelo-msft commented Aug 3, 2023

@tg-msft: it would be good to scope this to DPG libraries; consider pointing customers to RequestContext to control error experience.

It would be good to understand the experience in the HLC libraries as well.

@annelo-msft annelo-msft assigned JoshLove-msft and unassigned kinelski Aug 3, 2023
@annelo-msft annelo-msft added this to the Backlog milestone Aug 3, 2023
@annelo-msft annelo-msft changed the title Consider not throwing for completed but unsuccessful operations Consider not throwing for completed but unsuccessful long-running operations Nov 1, 2023
@pallavit
Copy link
Member

Do we see us doing this for exsiting HLCs? For DPG and newer light-up APIs we already have a means to achieve this behavior albeit as an advanced scenario.

Do we see us changing this to mainstream scenario however?
/cc: @annelo-msft

@annelo-msft
Copy link
Member

@pallavit: @JoshLove-msft is driving this investigation and can make a recommendation based on his findings once available.

@pallavit
Copy link
Member

@JoshLove-msft could you please share your current thinking here?

@JoshLove-msft
Copy link
Member

JoshLove-msft commented Dec 20, 2023

The scope of my investigation was to determine whether or not the current shared source implementation actually aligns with the current guidelines and whether the guidelines may need updating to reflect the behavior.

The guidelines say that UpdateStatus should throw if the operation completed with a failed result. They also state that accessing the Operation Value property should rethrow the same exception for failed operations:

If the Value property is evaluated after the operation failed (HasValue is false and HasCompleted is true) throw the same exception as the one thrown when the operation failed.

The shared source implementation throws on failed results in UpdateStatus. It also throws the same exception when accessing Value.

So our official guidance in the implementation guidelines matches up with the Azure.Core shared source implementation.

The problem is that many LRO's created before the Azure.Core shared source implementation, such as Key Vault's , did the implementation themselves and do not follow the guidelines of throwing on a failed result from UpdateStatus. Changing this behavior from not throwing to throwing is a breaking change. I would recommend that these be left as is.

I do think there is room for improvement by adding a static analyzer. A simple analyzer could verify these conditions for any Operation subtype. For existing LROs that don't follow the pattern the analyzer can be disabled on a case by case basis. We could either repurpose this issue to track the static analyzer work, or open a separate issue for that and close this issue. @pallavit, any preference there?

@pallavit
Copy link
Member

Thank you for sharing the details @JoshLove-msft

I do think there is room for improvement by adding a static analyzer. A simple analyzer could verify these conditions for any Operation subtype. For existing LROs that don't follow the pattern the analyzer can be disabled on a case by case basis. We could either repurpose this issue to track the static analyzer work, or open a separate issue for that and close this issue. @pallavit, any preference there?

As for this, I think we should open a bug in azure-sdk-tools for static analyzer. I agree with you that older SDKs would likely not be updated due to breaking changes concerns however this may be valuable for net new SDKs branded as well as other 3rd party scenarios in future. Even though LROs is a azure specific concept it may be worth evaluating it for the new toolchain as well so having a static analyzer bug for this will be useful. I would suggest tagging that issue with System.ClientModel as well so we think this scenario from that perspective as well. Let me know what you think?

@JoshLove-msft
Copy link
Member

JoshLove-msft commented Dec 20, 2023

Works for me - filed Azure/azure-sdk-tools#7478.

@annelo-msft
Copy link
Member

annelo-msft commented Jan 2, 2024 via email

@github-actions github-actions bot locked and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

No branches or pull requests

6 participants