Skip to content

[translation] account for nonstandard LRO status strings #17344

@kristapratico

Description

@kristapratico

The service will return "Cancelled" (with two "l"s), "Cancelling", and "ValidationFailed".

Here are the status strings that azure-core polling currently checks to see if the operation has reached a terminal state: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/azure/core/polling/base_polling.py#L52-L54

We need to check for these nonstandard statuses or the LRO will run forever.

Options:

  1. Simply map the nonstandard statuses to those of the ones checked in the get_status method:
            if status:
                if status == "ValidationFailed":
                    return "Failed"
                elif status in ["Cancelled", "Cancelling"]:
                    return "Canceled"
                return status
            else:
                raise BadResponse("No status found in body")
  1. Define a custom polling method that will inherit from LROBasePolling and override the methods checking for a terminal state like here in Text Analytics: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_lro.py#L32

I favor option 1, but we might need to re-evaluate if it makes sense with the current error states of the service. E.g. if we map "ValidationFailed" to a status == "Failed", now we will throw an exception instead of just returning the JobStatusDetail when wait_until_done is called by the user.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions