Ticket27342: poor error handling (env vars in config is not okay)#244
Ticket27342: poor error handling (env vars in config is not okay)#244
Conversation
They don't work with ExtendedInterpolation. I don't know how we ever
thought they were okay.
For example, chainging sbws_home from ~/.sbws to $HOME/.sbws
(venv-test) matt@spacecow:~/src/simple-bw-scanner$ sbws scanner
Traceback (most recent call last):
File "/home/matt/src/simple-bw-scanner/venv-test/bin/sbws", line 11, in <module>
sys.exit(main())
File "/home/matt/src/simple-bw-scanner/venv-test/lib/python3.5/site-packages/sbws/sbws.py", line 46, in main
_ensure_dirs(conf)
File "/home/matt/src/simple-bw-scanner/venv-test/lib/python3.5/site-packages/sbws/sbws.py", line 24, in _ensure_dirs
os.makedirs(conf.getpath('paths', 'datadir'), exist_ok=True)
File "/usr/lib/python3.5/configparser.py", line 806, in _get_conv
**kwargs)
File "/usr/lib/python3.5/configparser.py", line 800, in _get
return conv(self.get(section, option, **kwargs))
File "/usr/lib/python3.5/configparser.py", line 797, in get
d)
File "/usr/lib/python3.5/configparser.py", line 454, in before_get
self._interpolate_some(parser, option, L, value, section, defaults, 1)
File "/usr/lib/python3.5/configparser.py", line 510, in _interpolate_some
depth + 1)
File "/usr/lib/python3.5/configparser.py", line 517, in _interpolate_some
"found: %r" % (rest,))
configparser.InterpolationSyntaxError: '$' must be followed by '$' or '{', found: '$HOME/.sbws'
This commit changes Tor's run_dpath from $XDG_RUNTIME_DIR/sbws to
${tor:datadir}/run (which is ~/.sbws/tor/run by default)
|
How did the tox tests pass with these errors in the config? |
|
Yes I think that should be possible and straight forward. I'll add a test that makes sure an environment variable isn't interpolated in the config (less interesting) and a test that tries launching sbws from scratch in a new processes and making sure it runs as expected (more interesting). |
|
Sorry for my part in that bug. |
How can I reproduce the error you are seeing?
I don't want to support this environment variable as a special case. |
That's the default case in system packages (Debian). |
oh, sorry, that only happens in a chroot, so it's fine. |
|
I'd improve the message: To say something like |
I get the following, which is correct and expected.
When creating the Debian package, you can include a config file that sets these paths to be the exact right places, right? |
i do not include any config file in the debian package and that is intentional, since updates should not modify files that the user might modify. The commit message in 79fdb92 is not correct. ExtendedInterpolation does support environment variables. And the traceback says the error: The only change required is s/$/$$/:
Changing that i get: |
|
That's great news and means I can undo just about everything I did, thanks. |
|
i would keep the original title for this message
|
|
Commit 6c00e2a should remain. We should still change the info message to say what the user should do |
See https://trac.torproject.org/projects/tor/ticket/27358 for that. Closing this in favor of that ticket, plus one I will create for making a test that launches sbws from the command line to hopefully catch something like this in the future. |
I'm embarrassed we even let this happen. Sbws would not start for me. See commit messages.