alexdlaird / pyngrok

A Python wrapper for ngrok
https://pyngrok.readthedocs.io
MIT License
416 stars 59 forks source link

raise ValueError("No closing quotation") ValueError: No closing quotation #106

Closed N0tA1dan closed 1 year ago

N0tA1dan commented 1 year ago

any time i install pyngrok on windows 10 it gives me this error

log = self._log_line(line)
  File "C:\Users\Aidan's\AppData\Roaming\Python\Python310\site-packages\pyngrok\process.py", line 103, in _log_line
    log = NgrokLog(line)
  File "C:\Users\Aidan's\AppData\Roaming\Python\Python310\site-packages\pyngrok\process.py", line 204, in __init__
    for i in shlex.split(self.line):
  File "C:\Program Files\Python310\lib\shlex.py", line 315, in split
    return list(lex)
  File "C:\Program Files\Python310\lib\shlex.py", line 300, in __next__
    token = self.get_token()
  File "C:\Program Files\Python310\lib\shlex.py", line 109, in get_token
    raw = self.read_token()
  File "C:\Program Files\Python310\lib\shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation

I dont know why. I tried uninstalling and reinstalling but nothing worked. Please help

alexdlaird commented 1 year ago

I think I know where this comes from, will likely need to issue a patch. However, can you also share your app code, so I can understand better the inception of the error from an application perspective?

If possible, it'd also be great if you could drop a breakpoint in here to capture what the value raised is supposed to be, that way we can fix two problems at one (because once we fix the issue in reporting what the ValueError is, it's going to show us the real underlying exception).

alexdlaird commented 1 year ago

Actually, I've added a test case where I thought this might be coming from, it passes. We're using shlex.split to parse log lines, so the likely issue is the given log line isn't compatible with Unix shell syntax—so without seeing the log line at hand, I'm not sure we can debug further. Hopefully you can provide more info so we can make this actionable.

alexdlaird commented 1 year ago

Without an example, the only way I can get this error to be raised is with an example like this:

        from pyngrok.process import NgrokLog

        NgrokLog("lvl=WARN msg=Tom's")

But this is invalid anyway. If special characters are going to be used within valid Unix-style syntax, they should be in quotes—you'd see the same issue putting spaces in a test, for example:

        NgrokLog("lvl=WARN msg=Hello world")

will only produce 'hello' as the msg. Valid syntax in both cases would be:

        NgrokLog("lvl=WARN msg=\"Test=This is Tom's test\"")
        NgrokLog("lvl=WARN msg=\"Hello world\"")

The CI/CD pipeline also runs against Windows, so without further information given for what the error message populating (which would help us deduce where it's coming from / if it's user / environmental / ngrok error, or an actual issue with pyngrok), I'm going to close this ticket as invalid. If further information is provided in terms of the executing command / environment details, or a debug trace of the actual error message that is failing to be parsed, we can reopen.

Note that NgrokLog message syntaxes is tested here.