Skip to content

display acme.Errors less verbosely - #9255

Merged
bmw merged 2 commits into
certbot:masterfrom
alexzorin:improve-acme-error-printing
Mar 31, 2022
Merged

bmw merged 2 commits into
certbot:masterfrom
alexzorin:improve-acme-error-printing

Conversation

@alexzorin

Copy link
Copy Markdown
Collaborator

In #9233 we noticed that the way Certbot displays ACME errors is pretty verbose, due to the implementation of acme.messages.Error.__str__.

The idea in this PR is to display the most relevant information about ACME errors, which is the problem title and detail. Both of these come from the ACME server directly and are most likely to contain the most useful information.

Failing that, we can fall back to the RFC8555-based interpretation of the error type, which Certbot implements as description. Take note of jsha's comment about Certbot's implementation of description here: #6392 (comment).

If there is no description, we fall back to the type on its own.

Overall I hope this is friendlier than a very long line of redundant information. In practice I think this is going to depend on how well written the detail field coming from CAs is.

Possibly we can continue to always show the type, maybe without the ACME prefix. I chose not to, but open to other opinions.

cc @osirisinferi


Currently master looks something like:

image

This PR shrinks it down to the following (the ACME server just sends detail in this case):

image

@osirisinferi

Copy link
Copy Markdown
Collaborator

I also didn't do that in #9233, but might it be a good idea to also add a test for when error.typ does not exist in the ERROR_CODES mapping? Especially if the Boulder team is actually recommending "against" such a mapping? E.g., RFC 8555 specifies the "userActionRequired" type (https://datatracker.ietf.org/doc/html/rfc8555#section-6.7), which is not included in the mapping.

Also, currently (i.e., in master) the logging function also removes the ACME error "typ", but wouldn't we want this verbosity to exist in the log file? Just in case? Users normally don't go looking in log files, so no harm in extra verbosity there, right?

@alexzorin

alexzorin commented Mar 31, 2022 •

Copy link
Copy Markdown
Collaborator Author

might it be a good idea to also add a test for when error.typ does not exist in the ERROR_CODES mapping?

I agree. I am relying on implementation of the description property to protect us from this:

>>> print(messages.Error(typ="urn:ietf:params:acme:error:caa").description)
Certification Authority Authorization (CAA) records forbid the CA from issuing a certificate
>>> print(messages.Error(typ="foobaz").description)
None

If it's not there, this should display the raw type. Hopefully it's never the case in practice that title and detail are missing AND the type is unknown.

Edit: I may have misread, you may have meant a literal unit test. I think test_unknown_type covers this?

Also, currently (i.e., in master) the logging function also removes the ACME error "typ", but wouldn't we want this verbosity to exist in the log file? Just in case?

Yep, agreed. Both locations where we use this function already send the full error to the log file.

@osirisinferi

osirisinferi commented Mar 31, 2022 •

Copy link
Copy Markdown
Collaborator

Edit: I may have misread, you may have meant a literal unit test. I think test_unknown_type covers this?

Correct, I meant a unit test. I'm not familiair enough with Python unit tests/coverage, but if no such test is required in main_test.py if there is a test already in internal_util_test.py then I haven't said anything. :)

@bmw bmw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bmw
bmw merged commit fe0b637 into certbot:master Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants