Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if the environment contains any variable with "\u", arouteserver fails #50

Closed
sthen opened this issue Oct 6, 2019 · 4 comments
Closed

Comments

@sthen
Copy link

sthen commented Oct 6, 2019

Noticed because my usual shell prompt in $PS1 has "\u" in it to show my username, the presence of "\u" in any environment variable causes arouteserver to fail like this:

$ export FOO='\u'
$ arouteserver show_config 
ARouteServer 2019-10-06 17:39:04,919 ERROR An unexpected error occurred: bad escape \u at position 0

Please consider reporting this issue to the author using the URL below, including the following traceback and some hints on how to reproduce it: https://github.com/pierky/arouteserver/issues

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/sre_parse.py", line 1021, in parse_template
    this = chr(ESCAPES[this][1])
KeyError: '\\u'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/arouteserver", line 64, in <module>
    if main():
  File "/usr/local/bin/arouteserver", line 53, in main
    return cmd.run()
  File "/usr/local/lib/python3.7/site-packages/pierky/arouteserver/commands/show_config.py", line 46, in run
    self.show_config(current_config_path, sys.stdout)
  File "/usr/local/lib/python3.7/site-packages/pierky/arouteserver/commands/show_config.py", line 70, in show_config
    distrib._load_from_yaml("cfg:\n"
  File "/usr/local/lib/python3.7/site-packages/pierky/arouteserver/config/base.py", line 87, in _load_from_yaml
    expanded_doc = expand_env_vars(expanded_doc)
  File "/usr/local/lib/python3.7/site-packages/pierky/arouteserver/config/base.py", line 81, in expand_env_vars
    res = re.sub("\$\{" + v + "\}", os.environ[v], res)
  File "/usr/local/lib/python3.7/re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/local/lib/python3.7/re.py", line 309, in _subx
    template = _compile_repl(template, pattern)
  File "/usr/local/lib/python3.7/re.py", line 300, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "/usr/local/lib/python3.7/sre_parse.py", line 1024, in parse_template
    raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \u at position 0
@pierky
Copy link
Owner

pierky commented Oct 6, 2019

Hello @sthen, thanks for reporting this.

I've just pushed a fix, it's in the "dev" branch now, but also a CI/CD pipeline is running https://travis-ci.org/pierky/arouteserver/builds/594270338 and if everything will work as expected, a pre-release (v0.22.2-alpha1 ) will be pushed to the PyPi testing environment.

If you want to test it, you'll be able to install it using the following instructions: https://arouteserver.readthedocs.io/en/latest/INSTALLATION.html#development-and-pre-release-versions

@sthen
Copy link
Author

sthen commented Oct 6, 2019

Thanks, confirmed that fixes it for me.

@pierky
Copy link
Owner

pierky commented Oct 6, 2019

The PyPi file has not been pushed yet because of some integration tests are failing on CentOS, but it's not related to this hot fix, it's just a matter of tuning the tests for the latest version 8, which has been released only recently.
Hopefully the pipeline should work now, and the pre-release should go out. After that, I'll push it upstream to master, hopefully tomorrow.

@pierky
Copy link
Owner

pierky commented Oct 7, 2019

Fixed in v0.22.2.

@pierky pierky closed this as completed Oct 7, 2019
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

No branches or pull requests

2 participants