Skip to content

Commit c3546dc

Browse files
committed
fix(secrets-store): replace empty except with explanatory comment + debug log
1 parent 4622fdb commit c3546dc

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

autosearch/core/secrets_store.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from __future__ import annotations
1919

20+
import logging
2021
import os
2122
import shlex
2223
import tempfile
@@ -28,6 +29,7 @@
2829
_fcntl = None
2930

3031
_FILE_INJECTED_VALUES: dict[str, str] = {}
32+
_log = logging.getLogger(__name__)
3133

3234

3335
def secrets_path() -> Path:
@@ -103,13 +105,15 @@ def write_secret(key: str, value: str, *, path: Path | None = None) -> None:
103105
try:
104106
target.chmod(0o600)
105107
except OSError:
106-
pass
108+
# Some filesystems reject chmod; the secret write itself still succeeded.
109+
_log.debug("Unable to chmod secrets file to 0600: %s", target, exc_info=True)
107110
finally:
108111
try:
109112
if temp_path is not None:
110113
os.unlink(temp_path)
111114
except FileNotFoundError:
112-
pass
115+
# Preserve the original write error if another cleanup path removed the temp file.
116+
_log.debug("Temporary secrets file already removed: %s", temp_path, exc_info=True)
113117
finally:
114118
if _fcntl is not None:
115119
_fcntl.flock(lock_fh.fileno(), _fcntl.LOCK_UN)

0 commit comments

Comments
 (0)