-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PubSub topic.create method should raise a Conflict error instead of RetryError/GaxError when topic exists #3175
Comments
@lukesneeringer This is part of a more general question: how / where should we re-wrap |
For anybody affected by this, to handle ALREADY_EXISTS exception you can use the following scheme: try:
# create topic
except Conflict as error:
# handle the current conflict exception
except RetryException as error:
status_code = error.cause.code()
if status_code == status_code.ALREADY_EXISTS:
# handle the already exists
else:
# nothing that we want just re-raise the exception
raise |
The correct answer is to have GAX raise these different kinds of errors, rather than the catch-all |
@lukesneeringer That would be much preferred to the current ad-hoc approach (only in use in one subpackage, though some other remappings also exist). |
@dhermes While your team is fixing the issue, can you to fix the subscription_create issue at the same time? |
@lukesneeringer Generalizing the solution from |
The issue within pubsub seems to be that the back-end API shifted from returning We should add a system test (or extend and existing one) to ensure that we don't regress whatever fix we apply now. |
* Add testing support for 'ALREADY_EXISTS' gRPC error code. * Cover both possible gRPC conflict error codes. Closes #3175. * Exercise conflict-on-create in systests for topic/sub/snap.
* Add testing support for 'ALREADY_EXISTS' gRPC error code. * Cover both possible gRPC conflict error codes. Closes googleapis#3175. * Exercise conflict-on-create in systests for topic/sub/snap.
* Add testing support for 'ALREADY_EXISTS' gRPC error code. * Cover both possible gRPC conflict error codes. Closes googleapis#3175. * Exercise conflict-on-create in systests for topic/sub/snap.
* Add testing support for 'ALREADY_EXISTS' gRPC error code. * Cover both possible gRPC conflict error codes. Closes googleapis#3175. * Exercise conflict-on-create in systests for topic/sub/snap.
Error is coming in below code when starting the server "(node:6924) UnhandledPromiseRejectionWarning: Error: 6 ALREADY_EXISTS: Resource already exists in the project (resource=serverone)." Any idea why this issue is coming. Same code is working on other server 'use strict'; const http = require('http'); // Imports the Google Cloud client library // Your Google Cloud Platform project ID // Instantiates a client // Reference a topic that has been previously created. createFlowControlledSubscription('dashboardConnector','serverone',1,10000); function createFlowControlledSubscription (topicName, subscriptionName, maxInProgress, maxBytes) { // References an existing topic, e.g. "my-topic" // Creates a new subscription, e.g. "my-new-subscription"
} |
Following the documentation from PubSub site if you run the example 2x it will generate the error:
However it should raise Conflict Error (google.cloud.exceptions.Conflict), because the API returns a 409 response.
You can see the status code using API Explorer:
https://developers.google.com/apis-explorer/#search/pubsub/pubsub/v1/pubsub.projects.topics.create
Full traceback on Python:
The text was updated successfully, but these errors were encountered: