Failed tasks no longer store traceback.#7065
Conversation
| raise ValueError("Immediate tasks must be async functions.") | ||
| raise NonAsyncImmediateTaskError(task_name=task.name) |
There was a problem hiding this comment.
When this happens, it's a programming error. This should not be user visible.
7a4572d to
633d6be
Compare
633d6be to
43966ea
Compare
ffcb19b to
0c2fc24
Compare
673f40c to
f10b3ba
Compare
c0a7cb3 to
fc3aef2
Compare
c216476 to
bbb4420
Compare
| tb_str = "".join(traceback.format_tb(tb)) | ||
| error = exception_to_dict(exc, tb_str) | ||
| error = {} | ||
| if tb: |
There was a problem hiding this comment.
Does this still happen? Don't we just want the error to be a single string like:
"Remote URL not found" or "Internal Error"?
There was a problem hiding this comment.
Can we maybe instead add the PLP000X codes here?
|
|
||
| def __str__(self): | ||
| return _("Domain name was not found for {}. Check if specified url is valid.").format( | ||
| self.url |
There was a problem hiding this comment.
We should not leak urls either...
| self.url = url | ||
|
|
||
| def __str__(self): | ||
| return _("Domain name was not found for {}. Check if specified url is valid.").format( |
There was a problem hiding this comment.
Domains in the context of Pulp may be misleading. "URL lookup failed." Should be sufficient.
| return _("Domain name was not found for {}. Check if specified url is valid.").format( | ||
| self.url | ||
| ) | ||
| return _("URL lookup failed.") |
There was a problem hiding this comment.
There's more leaked data with the other exceptions.
1d2e063 to
53f2f33
Compare
53f2f33 to
da90358
Compare
| return _("URL: {u} not supported.").format(u=self.url) | ||
|
|
||
|
|
||
| class ProxyAuthenticationRequiredError(PulpException): |
There was a problem hiding this comment.
Isn't this more a "ProxyAuthenticationFailedError"? At which point "ProxyAuthenticationError" carries the same information.
There was a problem hiding this comment.
Yes, but I was taking inspiration from HTTP 407, which has the same error name
| except (PulpException, PulpGlueException): | ||
| exc_type, exc, _ = sys.exc_info() | ||
| log_task_failed(task, exc_type, exc, None, domain) # Leave no traceback in logs |
There was a problem hiding this comment.
Comments are a delicate thing... They are not executed by the interpreter and usually ignored by humans. So I'd rather hint at "why" not at "what" you do here.
| except (PulpException, PulpGlueException): | |
| exc_type, exc, _ = sys.exc_info() | |
| log_task_failed(task, exc_type, exc, None, domain) # Leave no traceback in logs | |
| except (PulpException, PulpGlueException): | |
| # Log expected ways to fail without a stacktrace. | |
| exc_type, exc, _ = sys.exc_info() | |
| log_task_failed(task, exc_type, exc, None, domain) |
| exc_type, exc, tb = sys.exc_info() | ||
| await sync_to_async(task.set_failed)(exc, tb) | ||
| log_task_failed(task, exc_type, exc, tb, domain) | ||
| # Generic exception for user |
There was a problem hiding this comment.
Similarly here:
# Unexpected Exceptions are most probably a programming error.
# Log error with a stack trace and give a generic error (equivalent of HTTP 500) to the user.
603e033 to
7dfbdbe
Compare
Tracebacks can expose sensitive information from an exception via the API. This change stops this behavior by only logging tracebacks and not storing them inside of tasks.
7dfbdbe to
31cf791
Compare
Failed task tracebacks are currently a part of task model, it can expose sensitive information from an exception via the API. This change stops this behavior by only logging tracebacks and not storing them inside of tasks.
_execute_task and _aexecute_task are modified to log tracebacks for unknown exceptions but never save them to the Task record.
Task.set_failed() is updated to make the tb (traceback) argument optional.
A new PulpExceptionNoTraceback base class is added for known, user-facing errors (like a DNS failure) where the traceback is not useful and should not be logged.
A new DnsDomainNameException (inheriting from PulpExceptionNoTraceback) is added to handle DNS lookup failures (e.g., bad remote URLs) as a known user error.