Azure / Azure/azure-rest-api-specs

Delete returns successful even if the resource does not exist

Open
#20,331 2 comments 0 reactions 0 assignees View on GitHub
Container Instances Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
3d 2h
Merged PRs (30d)
424

Description

Hello,

I have been noticing a pattern for most of the azure resources I have played around with, The "Delete" operation does not return an error when the resource does not exist, what is the rationale behind this design and if this is a bug? Here is an example below:

```
nishantkumar@SUPERNO-KTK3FNI ~ % az container list -g nishkumar-rg
[]
nishantkumar@SUPERNO-KTK3FNI ~ % az container delete -g nishkumar-rg -n random-container
Are you sure you want to perform this operation? (y/n): y
nishantkumar@SUPERNO-KTK3FNI ~ % az container delete -g nishkumar-rg -n random-container --debug

cli.knack.cli: Command arguments: ['container', 'delete', '-g', 'nishkumar-rg', '-n', 'random-container', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'container': ['azure.cli.command_modules.container']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: container 0.002 1 11
cli.azure.cli.core: Total (1) 0.002 1 11
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 1 groups, 11 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : container delete
cli.azure.cli.core: Command table: container delete
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/nishantkumar/.azure/commands/2022-08-23.11-54-30.container_delete.11653.log'.
az_command_data_logger: command args: container delete -g {} -n {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x10216a7a0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x1021baef0>, .add_cache_arguments at 0x1021bb010>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x1021baf80>]
Are you sure you want to perform this operation? (y/n): y
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ContainerInstanceManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/nishantkumar/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /Users/nishantkumar/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos', 'tenant_region_scope': 'WW', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 3351bb97-9e06-4af7-8277-59450f7eb737
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/a3eeb848-665a-4dbf-80a4-eb460930fb23/resourceGroups/nishkumar-rg/providers/Microsoft.ContainerInstance/containerGroups/random-container?api-version=2021-09-01'
cli.azure.cli.core.sdk.policies: Request method: 'DELETE'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '3f47148e-22ac-11ed-9051-5a4e36a63f79'
cli.azure.cli.core.sdk.policies: 'CommandName': 'container delete'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-g -n --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.38.0 (HOMEBREW) azsdk-python-mgmt-containerinstance/9.1.0 Python/3.10.5 (macOS-12.5-arm64-arm-64bit)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "DELETE /subscriptions/a3eeb848-665a-4dbf-80a4-eb460930fb23/resourceGroups/nishkumar-rg/providers/Microsoft.ContainerInstance/containerGroups/random-container?api-version=2021-09-01 HTTP/1.1" 204 0
cli.azure.cli.core.sdk.policies: Response status: 204
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-deletes': '14998'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '5e197c1e-d4d9-4df3-86b2-508641b52902'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '5e197c1e-d4d9-4df3-86b2-508641b52902'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'JIOINDIACENTRAL:20220823T062434Z:5e197c1e-d4d9-4df3-86b2-508641b52902'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'Date': 'Tue, 23 Aug 2022 06:24:34 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies:
cli.knack.cli: Event: CommandInvoker.OnTransformResult [, ]
cli.knack.cli: Event: CommandInvoker.OnFilterResult []
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 0
cli.__main__: Command ran in 3.665 seconds (init: 0.079, invoke: 3.587)
telemetry.save: Save telemetry record of length 3048 in cache
telemetry.check: Negative: The /Users/nishantkumar/.azure/telemetry.txt was modified at 2022-08-23 11:51:06.957833, which in less than 600.000000 `

```

Contributor guide

Open the contributing guide

Research direction

Start with the az container delete command and the DELETE request to the Microsoft.ContainerInstance containerGroups endpoint using api-version=2021-09-01. Compare the reported 204 response with the API specification and determine whether the behavior is intended; done means recording the expected behavior or identifying a concrete specification change.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.