Reject ambiguous library names and empty library-set entries (#33)

* Reject ambiguous library names and empty library-set entries

get_library_id() silently picked the first library matching a
requested name, so two libraries sharing a name would sync whichever
happened to come first in the server's response - not necessarily the
one the operator meant. It now raises ConfigError when a name matches
more than one library.

resolve_libraries() rejects an empty entry produced by an empty
LIBRARY_ID, 'a::b', or a leading/trailing ':' the same way, instead of
silently logging 'library  not found' and moving on.

* Clarify get_library_id's ambiguity docstring and error message

Copilot review: the input can be a name or an ID, and the error said
'Library name' even for an ID collision; use neutral wording. Also
made the docstring's second sentence a complete one.

---------

Co-authored-by: Maxim Shulga <maxim.shulga@alludo.com>
This commit is contained in:
Maksim ShulgaandMaxim Shulga authored and GitHub committed 2026-08-03 18:38:06 +00:00
1 parent 6f8af2cfa4
commit ba5ad177b7
4 files changed
+86 -6

No files matched your search

+7 -1
View File
@@ -185,7 +185,13 @@ Acceptance criteria:
`seaf-cli list --json` is used instead of splitting the display columns,
which could not represent a library name or a path containing whitespace.
`list-remote` still uses the HTTP API rather than the CLI.
- [ ] Reject ambiguous library names and an empty requested library set.
- [x] Reject ambiguous library names and an empty requested library set.
`get_library_id` used to silently return the first library matching a
requested name, even if two libraries shared it; it now raises
`ConfigError` when a name matches more than one library ID.
`resolve_libraries` rejects an empty entry from `LIBRARY_ID` (an empty
string, or one produced by `"a::b"`/a leading or trailing `:`) the same
way. See `tests/test_libraries.py`.
### Runtime hardening