forked from orinoco/dump-things-server
While there is no technical restriction forbidding relative paths to be
specified for the store root or config file arguments, using relative
paths causes user pain when the backend store initialization fails deep
in the call stack with a cryptic ValueError about paths not being
absolute (record_dir.py:88).
This change improves the user experience by:
1. Resolving relative paths to absolute paths early using Path.resolve()
- Converts relative paths like './data' to full absolute paths
- Resolves symbolic links to canonical paths
- Normalizes path components (removes '..' and '.')
2. Checking path existence immediately after resolution
- Provides clear, early error messages if paths don't exist
- Fails fast at startup rather than during backend initialization
- Helps users quickly identify path specification errors
The backend stores (particularly RecordDirStore) require absolute paths
and will raise ValueError if given relative paths. By resolving paths
at the entry point, we ensure all downstream code receives absolute
paths and provide better error messages when paths are invalid.
This addresses the crash at:
File "dump_things_service/backends/record_dir.py", line 88
if not root.is_absolute():
raise ValueError(f'Store root is not absolute: {root}')
|
||
|---|---|---|
| .. | ||
| auth | ||
| backends | ||
| commands | ||
| export | ||
| patches | ||
| store | ||
| tests | ||
| __about__.py | ||
| __init__.py | ||
| api_key.py | ||
| config.py | ||
| conftest.py | ||
| converter.py | ||
| curated.py | ||
| dynamic_endpoints.py | ||
| exceptions.py | ||
| incoming.py | ||
| lazy_list.py | ||
| main.py | ||
| model.py | ||
| resolve_curie.py | ||
| token.py | ||
| utils.py | ||