lib.ec.secret_store.KvFile: Fail get() on directories
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 5m16s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m13s
CI / Packaging test (pull_request) Successful in 0s

A directory node of the store, the root included, stats as a directory, but
a get on it falls through to the key lookup below its parent and fails with
a FileNotFoundError naming a path the caller never asked for: get() on the
root fails with an empty name, get() on a branch with its parent's compound
path.

Raise IsADirectoryError from _get() when the path is a directory on the
host, after the compound and the blob lookups, so get() and stat() agree: a
directory stats as FT_DIR and refuses a get.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-11-07 06:54:16 +01:00
commit fae3390a50
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -82,6 +82,17 @@ async def run_tests() -> None:
except FileNotFoundError:
pass
# -- A directory refuses a get: stat() answers a directory,
# get() raises IsADirectoryError, the two agree
for path in ('', os.path.dirname(target)):
st = await store.stat(path)
assert st.ftype is FT_DIR
try:
await store.get(path)
raise AssertionError(f'expected IsADirectoryError for {path}')
except IsADirectoryError:
pass
# put writes a key into the entry file, merging with the
# existing keys
await store.put(f'{target}/key4', b'value4', ftype = FT_SECRET_KEY)