[Key Vault] Revise administration models - #19049
Conversation
| if error is None or error.code is None: | ||
| self._error = None | ||
| else: | ||
| self._error = ODataV4Format(vars(error)) |
There was a problem hiding this comment.
Small but important detail here: ODataV4Format expects the inner error to be labeled as innererror, but the error we get back labels it as inner_error and doesn't get applied to the resulting ODataV4Format object. Does it make sense to edit the label to be innererror, or would that be forcing a square peg into a round hole?
There was a problem hiding this comment.
ODataV4Format expects JSON deserialized to a dict but the Error class generated by autorest has already deserialized the JSON and Pythonified "innererror" to "inner_error". What do you get from error.as_dict()? Also, ODataV4Format.innererror should be a JSON dict as well--it's JSON dicts all the way down.
There was a problem hiding this comment.
error.as_dict() gives the same dictionary as vars(dict) -- we're still left with an inner_error key 😕
There was a problem hiding this comment.
Can you use the key_transformer argument to rename it?
There was a problem hiding this comment.
Okay nice, that does work with something like:
def my_key_transformer(key, attr_desc, value):
if key == "inner_error":
return ("innererror", value)
return (key, value)for errors with no inner error (error.inner_error = None) and errors with JSON dict inner errors (they get recursively renamed)
There was a problem hiding this comment.
It looks like something like this would work as well:
error.as_dict(key_transformer=lambda k, _, v: ("innererror", v) if k == "inner_error" else (k, v))|
Closing, since other changes that affect these are being done in #19099. |
Resolves #13575 and resolves #18992.