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

[ServiceBus] Connection error with unknown condition code to be ServiceBusConnectionError instead of ServiceBusError #15688

Closed
yunhaoling opened this issue Dec 7, 2020 · 0 comments
Assignees
Labels
blocking-release Blocks release Client This issue points to a problem in the data-plane of the library. Service Bus
Milestone

Comments

@yunhaoling
Copy link
Contributor

yunhaoling commented Dec 7, 2020

Right now, if there's a connection error happening with condition unknown, a ServiceBusError is throwed due to the current condition based exception handling -- condition code b"amqp:unknown-error" is not in the condition-error mapping and default to ServiceBusError.

However, I think this could be improved by raising ServiceBusConnectionError if the error condition is unknown to be more detailed.

This is a non-breaking change.

To be more specific, it's this part of the code that should be improved:

def _handle_amqp_exception_with_condition(
logger,
condition,
description,
exception=None,
status_code=None
):
#
# handling AMQP Errors that have the condition field or the mgmt handler
logger.info("AMQP error occurred: (%r), condition: (%r), description: (%r).", exception, condition, description)
if condition == AMQPErrorCodes.NotFound:
# handle NotFound error code
error_cls = ServiceBusCommunicationError \
if isinstance(exception, AMQPErrors.AMQPConnectionError) else MessagingEntityNotFoundError
elif condition == AMQPErrorCodes.ClientError and 'timed out' in str(exception):
# handle send timeout
error_cls = OperationTimeoutError
else:
# handle other error codes
error_cls = _ERROR_CODE_TO_ERROR_MAPPING.get(condition, ServiceBusError)
error = error_cls(message=description, error=exception, condition=condition, status_code=status_code)
if condition in _NO_RETRY_CONDITION_ERROR_CODES:
error._retryable = False # pylint: disable=protected-access
return error

@yunhaoling yunhaoling added Service Bus Client This issue points to a problem in the data-plane of the library. labels Dec 7, 2020
@yunhaoling yunhaoling added this to the Backlog milestone Dec 7, 2020
@yunhaoling yunhaoling self-assigned this Dec 7, 2020
@yunhaoling yunhaoling changed the title [ServiceBus] Connection error with unknown condition code to be ServiceBusConnectionError [ServiceBus] Connection error with unknown condition code to be ServiceBusConnectionError instead of ServiceBusError Dec 7, 2020
@yunhaoling yunhaoling modified the milestones: Backlog, [2021] March Feb 9, 2021
@yunhaoling yunhaoling added the blocking-release Blocks release label Feb 11, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocking-release Blocks release Client This issue points to a problem in the data-plane of the library. Service Bus
Projects
None yet
Development

No branches or pull requests

1 participant