You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not possible to set an environment variable such as url_prefix: ${PYGEOAPI_PREFIX:-} such that, if PYGEOAPI_PREFIX is undefined, no url_prefix is set.
I've tried ${PYGEOAPI_PREFIX:-""}, to no avail (url becomes /""/etc).
Steps to Reproduce
add url_prefix: ${PYGEOAPI_PREFIX:-} to the server api_rules in config.yml
Expected behavior
If PYGEOAPI_PREFIX is set, use this value. If it is not set, do not use a url_prefix
Screenshots/Tracebacks
If applicable, add screenshots to help explain your problem.
backend-1 | File "/opt/conda/envs/backend/lib/python3.11/site-packages/pygeoapi/starlette_app.py", line 86, in <module>
backend-1 | api_ = API(CONFIG, OPENAPI)
backend-1 | ^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/opt/conda/envs/backend/lib/python3.11/site-packages/pygeoapi/api/__init__.py", line 658, in __init__
backend-1 | self.base_url = get_base_url(self.config)
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/opt/conda/envs/backend/lib/python3.11/site-packages/pygeoapi/util.py", line 216, in get_base_url
backend-1 | return url_join(config['server']['url'], rules.get_url_prefix())
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^
backend-1 | File "/opt/conda/envs/backend/lib/python3.11/site-packages/pygeoapi/models/config.py", line 95, in get_url_prefix
backend-1 | prefix = self.url_prefix.format(
backend-1 | ^^^^^^^^^^^^^^^^^^^^^^^
backend-1 | KeyError: 'PYGEOAPI_PREFIX'
Description
It's not possible to set an environment variable such as
url_prefix: ${PYGEOAPI_PREFIX:-}
such that, if PYGEOAPI_PREFIX is undefined, no url_prefix is set.I've tried
${PYGEOAPI_PREFIX:-""}
, to no avail (url becomes /""/etc).Steps to Reproduce
add
url_prefix: ${PYGEOAPI_PREFIX:-}
to the server api_rules in config.ymlExpected behavior
If PYGEOAPI_PREFIX is set, use this value. If it is not set, do not use a url_prefix
Screenshots/Tracebacks
If applicable, add screenshots to help explain your problem.
Environment
Additional context
It seems like an issue in the yaml parsing,
pygeoapi/pygeoapi/util.py
Line 171 in 6682b44
the regex
r'.*?\$\{(?P<varname>\w+)(:-(?P<default>[^}]+))?\}'
could be changed tor'.*?\$\{(?P<varname>\w+)(:-(?P<default>[^}]*))?\}'
The text was updated successfully, but these errors were encountered: