fix: handle OSError when age keys are too long to be file paths

Prevents "File name too long" errors when users provide age keys directly
to 'clan secrets users add', as Path.is_file() would fail before the key
validation could run.

Fixes: https://git.clan.lol/clan/clan-core/issues/5522
This commit is contained in:
Jörg Thalheim
2025-10-14 13:15:54 +01:00
parent c2a71fb423
commit 9469968851

View File

@@ -22,7 +22,13 @@ def secret_name_type(arg_value: str) -> str:
def public_or_private_age_key_type(arg_value: str) -> str:
if Path(arg_value).is_file():
try:
is_file = Path(arg_value).is_file()
except OSError:
# Handle "File name too long" errors when age keys are passed directly
is_file = False
if is_file:
arg_value = Path(arg_value).read_text().strip()
elif arg_value.startswith("AGE-PLUGIN-"):
msg = (