-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
More useful exceptions for Key Vault errors #7086
Conversation
Can one of the admins verify this patch? |
sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_shared/exceptions.py
Outdated
Show resolved
Hide resolved
sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_shared/exceptions.py
Outdated
Show resolved
Hide resolved
_error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} | ||
|
||
|
||
def raise_from_key_vault_exception(exception): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious as to why we couldn't use the error_map
parameter instead of creating yet another way of mapping errors from autorest generated code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, I've reworked this to do that.
008f121
to
2fbee7a
Compare
c9b3d9a
to
841ef7e
Compare
2d12853
to
c9f17fc
Compare
* Update msrest and regenerate swagger. (#7308) * Update msrest and regenerate swagger. * override to get green CI. * Fix to have no content type when request body is empty (#7343) * Correct return types for list_secrets, _versions (#7268) * More useful exceptions for Key Vault errors (#7086) * Fix to have no content type when request body is empty * [Blob] Set tier and rehydrate (#7269) * [BlockBlob][Tier]Add BlobTier Support For CopyBlob/PutBlob/PutBlockList * [BlockBlob][Tier]Add Recordings for Standard BlobTier Support * [BlockBlob][Rehydrate]Enable Rehydrate Priority for Copy/SetTier * [BlockBlob][Rehydrate]Recordings for Rehydrate Priority for Copy/SetTier * [Blob] Echo client (#7350) * [EchoClientId]Verify Client Request ID in Response Same as in Request * [BlockBlob][Rehydrate]Fix Recordings * Refactor max_connections to max_concurrency (#7531) * Rename max_connections to max_concurrency * Other non breaking changes * comment changes * Use generated version as constant API version (#7547) * Re-recording from #7555 (#7585) * Storage batch API (#7387) * delete_blobs POC * Storage POC WIP * Storage POC async * Storage WIP * Storage clean-up * Storage options * Autorest remark * Use config option * SetBlobTier WIP * Working and tested delete_blobs + options * Set standard tier with tests * Adapt tests for playback mode * Move batch_send to common mixin * Python 2.7 compat * Fix snapshot bug * Re-record * Pass kwargs to batch * Clean x-ms-client-request-id from body if multipart response * remove duplicated comp=tier * Disable batch tests on Python 2.7 * pylint * Batch ChangeLog (#7593) * [Storage Blob] Regenerate Swagger (#7572) * Regenerate Swagger * small fix * adjusts literalincludes for msft docs (#7599) * Download sparse blob (#7555) * [PageBlob]Optimize Download Sparse File * Breaking Changes - Permission models (#7517) * Rename Permission related models to SasPermissions * Rewrite Permission Models * refactor tests * some tests * comment changes * remove length checks * QueuePermissions * File Permissions * blobs minor tweaks * minor fix * pylint fix * pylint * Fix batch docstrings (#7600) * Fix batch docstrings * pylint * [Rename]rename max_connections to max_concurrency (#7606) * small edits to lease client docs (#7550) * small edits to lease client docs * whitespace * Setup identity for unified pipelines. (#7578) * Setup keyvault for unified pipelines. (#7579) * Setup eventhubs for publishing via unified pipelines. (#7580) * Setup eventhubs for publishing via unified pipelines. * Fixed missing punctuation. * Setup cosmos for release via unified pipelines. (#7581) * bump CI * Manual network september (#7576) * generated files * adding 2019-07-01 * history and version * rerun tests * updated version * removed subscription id from tests * rerun tests again * replaced subscription id * [AutoPR] reservations/resource-manager (#7569) * [AutoPR reservations/resource-manager] [Hub Generated] Review request for Microsoft.Capacity to add version preview/2019-04-01 (#7251) * Generated from f19a2e5b7f384018b74b21b7b8b8782d95b456f9 fixed x-ms-enum value * Generated from 2f56008117d578bec6cc8b8c832926f45a0fe52e fixed catalog definition * Generated from cac978330e8c7b9583812a735cfeac97fb267056 reverted breaking operation id change * added version and history * [AutoPR] sql/resource-manager (#7535) * Generated from 9402dbf3fb3d5fffcb80f501b1fc857ff97ab723 (#7329) Fixing PR validation errors * regenerated * history and version * Setup app configuration with unified pipelines. (#7582) * [AutoPR] resources/resource-manager (#7549) * regenerated * updated history and version * updated date * Correct import_key parameter type (#7590) * add doc for tracing (#7616) * Add a from_blob_url method (#7567) * Add a from_blob_url method * Update tests * Recordings - common blob * Revert "Recordings - common blob" This reverts commit ad07f34c25f7662cbaed8b33ac05a1a6f6270dae. * comment changes * undo get_client changes * redo recordings * from_container_url * fix tests * tests fix for container url * pylint fix * Fix some docstring * docstrings * Doc imprvment for Storage (#7601) * Docstring improvement * File docstring * Queue docstrings * More doc fixes * More doc fixes * Revert "small edits to lease client docs (#7550)" (#7631) This reverts commit ed20b58. * kwarg-ify methods (#7611) * changeset1 * changeset-2 * changeset-3 * changeset-4 * minor fix * some final tweaks * pylint * minor fixes * max_concurrency * lease_id * pylint * fix * [Storage] Consolidate offset and range parameters (#7598) * Updated blob sync tests * Offset refactor APIS (#19) * rename to offset and length * fix * more changes * Updated blob sync tests * Temp block async tests * Fix upload page behaviour * Fix clear page behaviour * Update from_url offset behaviour * Update page ranges * Fix download blob behaviour * Some cleanup * Fixed page size * More test fixes * Some more fixes * Fixed page tests * Fixed encryption tests * Fix common test * append anf page blob async * some more test fixes * Fix live tests * more changes async * Fix sparse blob test * Last tests * update docstrings * pylint * Some Final tweaks (#7653) * Some final tweaks * comments * Fix live tests (#7665) * fix live tests * oops * few changes
* Update msrest and regenerate swagger. (Azure#7308) * Update msrest and regenerate swagger. * override to get green CI. * Fix to have no content type when request body is empty (Azure#7343) * Correct return types for list_secrets, _versions (Azure#7268) * More useful exceptions for Key Vault errors (Azure#7086) * Fix to have no content type when request body is empty * [Blob] Set tier and rehydrate (Azure#7269) * [BlockBlob][Tier]Add BlobTier Support For CopyBlob/PutBlob/PutBlockList * [BlockBlob][Tier]Add Recordings for Standard BlobTier Support * [BlockBlob][Rehydrate]Enable Rehydrate Priority for Copy/SetTier * [BlockBlob][Rehydrate]Recordings for Rehydrate Priority for Copy/SetTier * [Blob] Echo client (Azure#7350) * [EchoClientId]Verify Client Request ID in Response Same as in Request * [BlockBlob][Rehydrate]Fix Recordings * Refactor max_connections to max_concurrency (Azure#7531) * Rename max_connections to max_concurrency * Other non breaking changes * comment changes * Use generated version as constant API version (Azure#7547) * Re-recording from Azure#7555 (Azure#7585) * Storage batch API (Azure#7387) * delete_blobs POC * Storage POC WIP * Storage POC async * Storage WIP * Storage clean-up * Storage options * Autorest remark * Use config option * SetBlobTier WIP * Working and tested delete_blobs + options * Set standard tier with tests * Adapt tests for playback mode * Move batch_send to common mixin * Python 2.7 compat * Fix snapshot bug * Re-record * Pass kwargs to batch * Clean x-ms-client-request-id from body if multipart response * remove duplicated comp=tier * Disable batch tests on Python 2.7 * pylint * Batch ChangeLog (Azure#7593) * [Storage Blob] Regenerate Swagger (Azure#7572) * Regenerate Swagger * small fix * adjusts literalincludes for msft docs (Azure#7599) * Download sparse blob (Azure#7555) * [PageBlob]Optimize Download Sparse File * Breaking Changes - Permission models (Azure#7517) * Rename Permission related models to SasPermissions * Rewrite Permission Models * refactor tests * some tests * comment changes * remove length checks * QueuePermissions * File Permissions * blobs minor tweaks * minor fix * pylint fix * pylint * Fix batch docstrings (Azure#7600) * Fix batch docstrings * pylint * [Rename]rename max_connections to max_concurrency (Azure#7606) * small edits to lease client docs (Azure#7550) * small edits to lease client docs * whitespace * Setup identity for unified pipelines. (Azure#7578) * Setup keyvault for unified pipelines. (Azure#7579) * Setup eventhubs for publishing via unified pipelines. (Azure#7580) * Setup eventhubs for publishing via unified pipelines. * Fixed missing punctuation. * Setup cosmos for release via unified pipelines. (Azure#7581) * bump CI * Manual network september (Azure#7576) * generated files * adding 2019-07-01 * history and version * rerun tests * updated version * removed subscription id from tests * rerun tests again * replaced subscription id * [AutoPR] reservations/resource-manager (Azure#7569) * [AutoPR reservations/resource-manager] [Hub Generated] Review request for Microsoft.Capacity to add version preview/2019-04-01 (Azure#7251) * Generated from f19a2e5b7f384018b74b21b7b8b8782d95b456f9 fixed x-ms-enum value * Generated from 2f56008117d578bec6cc8b8c832926f45a0fe52e fixed catalog definition * Generated from cac978330e8c7b9583812a735cfeac97fb267056 reverted breaking operation id change * added version and history * [AutoPR] sql/resource-manager (Azure#7535) * Generated from 9402dbf3fb3d5fffcb80f501b1fc857ff97ab723 (Azure#7329) Fixing PR validation errors * regenerated * history and version * Setup app configuration with unified pipelines. (Azure#7582) * [AutoPR] resources/resource-manager (Azure#7549) * regenerated * updated history and version * updated date * Correct import_key parameter type (Azure#7590) * add doc for tracing (Azure#7616) * Add a from_blob_url method (Azure#7567) * Add a from_blob_url method * Update tests * Recordings - common blob * Revert "Recordings - common blob" This reverts commit ad07f34c25f7662cbaed8b33ac05a1a6f6270dae. * comment changes * undo get_client changes * redo recordings * from_container_url * fix tests * tests fix for container url * pylint fix * Fix some docstring * docstrings * Doc imprvment for Storage (Azure#7601) * Docstring improvement * File docstring * Queue docstrings * More doc fixes * More doc fixes * Revert "small edits to lease client docs (Azure#7550)" (Azure#7631) This reverts commit ed20b58. * kwarg-ify methods (Azure#7611) * changeset1 * changeset-2 * changeset-3 * changeset-4 * minor fix * some final tweaks * pylint * minor fixes * max_concurrency * lease_id * pylint * fix * [Storage] Consolidate offset and range parameters (Azure#7598) * Updated blob sync tests * Offset refactor APIS (Azure#19) * rename to offset and length * fix * more changes * Updated blob sync tests * Temp block async tests * Fix upload page behaviour * Fix clear page behaviour * Update from_url offset behaviour * Update page ranges * Fix download blob behaviour * Some cleanup * Fixed page size * More test fixes * Some more fixes * Fixed page tests * Fixed encryption tests * Fix common test * append anf page blob async * some more test fixes * Fix live tests * more changes async * Fix sparse blob test * Last tests * update docstrings * pylint * Some Final tweaks (Azure#7653) * Some final tweaks * comments * Fix live tests (Azure#7665) * fix live tests * oops * few changes
* Update msrest and regenerate swagger. (#7308) * Update msrest and regenerate swagger. * override to get green CI. * Fix to have no content type when request body is empty (#7343) * Correct return types for list_secrets, _versions (#7268) * More useful exceptions for Key Vault errors (#7086) * Fix to have no content type when request body is empty * [Blob] Set tier and rehydrate (#7269) * [BlockBlob][Tier]Add BlobTier Support For CopyBlob/PutBlob/PutBlockList * [BlockBlob][Tier]Add Recordings for Standard BlobTier Support * [BlockBlob][Rehydrate]Enable Rehydrate Priority for Copy/SetTier * [BlockBlob][Rehydrate]Recordings for Rehydrate Priority for Copy/SetTier * [Blob] Echo client (#7350) * [EchoClientId]Verify Client Request ID in Response Same as in Request * [BlockBlob][Rehydrate]Fix Recordings * Refactor max_connections to max_concurrency (#7531) * Rename max_connections to max_concurrency * Other non breaking changes * comment changes * Use generated version as constant API version (#7547) * Re-recording from #7555 (#7585) * Storage batch API (#7387) * delete_blobs POC * Storage POC WIP * Storage POC async * Storage WIP * Storage clean-up * Storage options * Autorest remark * Use config option * SetBlobTier WIP * Working and tested delete_blobs + options * Set standard tier with tests * Adapt tests for playback mode * Move batch_send to common mixin * Python 2.7 compat * Fix snapshot bug * Re-record * Pass kwargs to batch * Clean x-ms-client-request-id from body if multipart response * remove duplicated comp=tier * Disable batch tests on Python 2.7 * pylint * Batch ChangeLog (#7593) * [Storage Blob] Regenerate Swagger (#7572) * Regenerate Swagger * small fix * adjusts literalincludes for msft docs (#7599) * Download sparse blob (#7555) * [PageBlob]Optimize Download Sparse File * Breaking Changes - Permission models (#7517) * Rename Permission related models to SasPermissions * Rewrite Permission Models * refactor tests * some tests * comment changes * remove length checks * QueuePermissions * File Permissions * blobs minor tweaks * minor fix * pylint fix * pylint * Fix batch docstrings (#7600) * Fix batch docstrings * pylint * [Rename]rename max_connections to max_concurrency (#7606) * small edits to lease client docs (#7550) * small edits to lease client docs * whitespace * Setup identity for unified pipelines. (#7578) * Setup keyvault for unified pipelines. (#7579) * Setup eventhubs for publishing via unified pipelines. (#7580) * Setup eventhubs for publishing via unified pipelines. * Fixed missing punctuation. * Setup cosmos for release via unified pipelines. (#7581) * bump CI * Manual network september (#7576) * generated files * adding 2019-07-01 * history and version * rerun tests * updated version * removed subscription id from tests * rerun tests again * replaced subscription id * [AutoPR] reservations/resource-manager (#7569) * [AutoPR reservations/resource-manager] [Hub Generated] Review request for Microsoft.Capacity to add version preview/2019-04-01 (#7251) * Generated from f19a2e5b7f384018b74b21b7b8b8782d95b456f9 fixed x-ms-enum value * Generated from 2f56008117d578bec6cc8b8c832926f45a0fe52e fixed catalog definition * Generated from cac978330e8c7b9583812a735cfeac97fb267056 reverted breaking operation id change * added version and history * [AutoPR] sql/resource-manager (#7535) * Generated from 9402dbf3fb3d5fffcb80f501b1fc857ff97ab723 (#7329) Fixing PR validation errors * regenerated * history and version * Setup app configuration with unified pipelines. (#7582) * [AutoPR] resources/resource-manager (#7549) * regenerated * updated history and version * updated date * Correct import_key parameter type (#7590) * add doc for tracing (#7616) * Add a from_blob_url method (#7567) * Add a from_blob_url method * Update tests * Recordings - common blob * Revert "Recordings - common blob" This reverts commit ad07f34c25f7662cbaed8b33ac05a1a6f6270dae. * comment changes * undo get_client changes * redo recordings * from_container_url * fix tests * tests fix for container url * pylint fix * Fix some docstring * docstrings * Doc imprvment for Storage (#7601) * Docstring improvement * File docstring * Queue docstrings * More doc fixes * More doc fixes * Revert "small edits to lease client docs (#7550)" (#7631) This reverts commit ed20b58. * kwarg-ify methods (#7611) * changeset1 * changeset-2 * changeset-3 * changeset-4 * minor fix * some final tweaks * pylint * minor fixes * max_concurrency * lease_id * pylint * fix * [Storage] Consolidate offset and range parameters (#7598) * Updated blob sync tests * Offset refactor APIS (#19) * rename to offset and length * fix * more changes * Updated blob sync tests * Temp block async tests * Fix upload page behaviour * Fix clear page behaviour * Update from_url offset behaviour * Update page ranges * Fix download blob behaviour * Some cleanup * Fixed page size * More test fixes * Some more fixes * Fixed page tests * Fixed encryption tests * Fix common test * append anf page blob async * some more test fixes * Fix live tests * more changes async * Fix sparse blob test * Last tests * update docstrings * pylint * Some Final tweaks (#7653) * Some final tweaks * comments * Fix live tests (#7665) * fix live tests * oops * few changes
This ensures exceptions raised in lieu of the autorest-generated
KeyVaultErrorException
surface Key Vault's error text.For example, given a 404 response,
ResourceNotFoundError
is more to the point thanKeyVaultErrorException
. We can use theerror_map
kwarg to raiseResourceNotFoundError
instead, but without some extra code as in this PR, Key Vault's error text isn't surfaced:KeyVaultErrorException: (KeyNotFound) Key not found: imaginary-key
error_map
:ResourceNotFoundError: Operation returned an invalid status 'Not Found'
ResourceNotFoundError: (KeyNotFound) Key not found: imaginary-key
Closes #7003