volitank / nala

Nala is a front-end for libapt-pkg.
GNU General Public License v3.0
1.44k stars 47 forks source link

Don't print stacktrace on standard error #1

Closed Lightjohn closed 2 years ago

Lightjohn commented 2 years ago

In the case of missing root or missing arguments all the stack is printed then the error message. Only the error message would be useful for standard known errors

From:

FileNotFoundError: [Errno 2] No such file or directory
Call stack:
  File "/build/nala-Skdmi8/nala-0.5.0/nala-cli.py", line 32, in <module>
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 209, in main
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 54, in _main
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 173, in sudo_check
Message: 'user tried to run [nala update] without permission'
Arguments: ()
Error: Nala needs root to update

To

Error: Nala needs root to update
volitank commented 2 years ago

Hi thanks for your bug report. Sorry it's taken so long to respond. We typically only look on GitLab for bug reports as this repo is just a mirror of that one.

I'm not going to make you resubmit, but in the future be aware I will likely respond faster that way.

This is a strange error, which is why it's printing the stack. I'm not exactly sure what file is not found here.

I'm guessing maybe /dev/log? Can you confirm if this exists on your system or not? If this is what is causing it then this should be fixed in the next release. I've taken out the logic to print to the syslog considering it's only used here and rather useless.

Lightjohn commented 2 years ago

I can put it on gitlab if you want.

let me give you more information: First this is run in wls so ubuntu 20 on windows. The command run was nala update without sudo

Full stack trace is

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/handlers.py", line 953, in emit
    self.socket.send(msg)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/handlers.py", line 874, in _connect_unixsocket
    self.socket.connect(address)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/logging/handlers.py", line 956, in emit
    self._connect_unixsocket(self.address)
  File "/usr/lib/python3.9/logging/handlers.py", line 885, in _connect_unixsocket
    self.socket.connect(address)
FileNotFoundError: [Errno 2] No such file or directory
Call stack:
  File "/build/nala-Skdmi8/nala-0.5.0/nala-cli.py", line 32, in <module>
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 209, in main
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 54, in _main
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 173, in sudo_check
Message: 'me tried to run [nala update] without permission'
Arguments: ()
Error: Nala needs root to update

But because nala search without argument was also throwing full stack trace:

Traceback (most recent call last):
  File "/build/nala-Skdmi8/nala-0.5.0/nala-cli.py", line 32, in <module>
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 209, in main
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 62, in _main
  File "/build/nala-Skdmi8/nala-0.5.0/nala/__main__.py", line 87, in apt_command
  File "/build/nala-Skdmi8/nala-0.5.0/nala/nala.py", line 189, in search
  File "/usr/lib/python3.9/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.9/re.py", line 303, in _compile
    raise TypeError("first argument must be string or compiled pattern")
TypeError: first argument must be string or compiled pattern

I assumed it was default behaviour... Maybe it's just two different cases.

Also on WLS there is no /dev/log so maybe the issue is more with WLS. Sorry for the lack of clarity

volitank commented 2 years ago

No worries. You don't have to put this on gitlab. I'm almost certain the issue here is that /dev/log doesn't exist and will be fixed in the next release. But I'll keep this open until then.

For search that is a different issue. When I implemented that I forgot to do argument checking before running the function. This one will most definitely be fixed in the next release.

In Nala all errors that I know about are handled properly. So if you come across a stack like this it's because there either is an error I haven't expected/know about or I've coded something improperly.

I only handle errors that I know about as I don't want to catch something too general and end up hiding something that needs to be fixed.

Lightjohn commented 2 years ago

Good news and thanks for this beautiful piece of software

volitank commented 2 years ago

No problem. Thank you for using Nala and reporting bugs for it. It wouldn't be half the program it is now with out the bug reports and feature requests I've received.

volitank commented 2 years ago

I'm going to go ahead and close this as I believe it may be resolved now

Lightjohn commented 2 years ago

Everything was fixed indeed, thanks