request for comment: specialized schema parse errors#318
request for comment: specialized schema parse errors#318blackboxsw wants to merge 1 commit intocanonical:mainfrom
Conversation
| raise LibNetplanException(err.contents.message.decode('utf-8')) | ||
| exception_cls = LibNetplanException | ||
| for error_format, error_type in GERROR_MESSAGE_FORMAT_EXCEPTION_MAP: | ||
| if re.match(error_format, err.contents.message.decode('utf-8')): |
There was a problem hiding this comment.
Alternatively, we could raise different err.contents.code values to represent different exception types because regex matching of err.contents.message format matching could be brittle if message format changes or with internationalization of error messages at some point.
slyon
left a comment
There was a problem hiding this comment.
Thank you, I like the idea of this RFC and there's some attempt going on in improving the overall exception handling of Netplan, which this PR should be merged into, IMO (see #334).
Longer term, we should absolutely differentiate the exceptions by error code directly at the origin in libnetplan.so, instead of parsing the error message in libnetplan.py.
|
Closing this in favor of #334 (which merged most this PR's concepts). @blackboxsw We'd be glad for your feedback/review on that follow-up PR, when you find some time. |
Description
@slyon thanks for the jira ping.
Request for comment as to whether this is the right approach to take to get more detailed schema errors (we could alternatively look to unique err.contents.code differences from the C library but we'd also still have to 'unpack' some encoded line/column and path values from the structured error messages in python.
Cloud-int would like to have specialized exception types from libnetplan for schema errors. The specialization needed would be attributes on the Exception raised which point to the offending config file path, the marked error line number and column number.
It seems that all libnetplan errors are generalized from the GERROR raised by the C code. If we can either specialize the err.contents.code for different types or errors, or allow for message format parsing in libnetplan:_checked_lib_call then cloud-init error handling and reporting from tooling can better know how to handle schema errors vs other errors raised by netplan.
Checklist
make checksuccessfully.make check-coverage).