Skip to content

Commit

Permalink
fix issue Azure#11658
Browse files Browse the repository at this point in the history
  • Loading branch information
changlong-liu committed May 29, 2020
1 parent 41116fa commit 0e37e00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ def is_valid_resource_id(rid, exception_type=None):
"""
is_valid = False
try:
is_valid = rid and resource_id(**parse_resource_id(rid)).lower() == rid.lower()
parsed_id = parse_resource_id(rid)
is_valid = rid and resource_id(**parsed_id).lower() == rid.lower() and all(
len(v) > 0 for k, v in parsed_id.items() if rid.find('/{}/'.format(k)) >= 0)

This comment has been minimized.

Copy link
@jiasli

jiasli Jun 4, 2020

How about using something like

True for k, v in parsed_id.items() if rid.find('/{}/'.format(k)) >= 0 and len(v) > 0 

On a second thought, maybe even parse_resource_id should fail if an empty name is encountered.

Anyway we need more test cases.

except KeyError:
pass
if not is_valid and exception_type:
Expand Down

0 comments on commit 0e37e00

Please sign in to comment.