Skip to content

Commit ef5deb7

Browse files
Copilotmnriem
andauthored
fix: use stable ~/.specify/auth.json in rate-limit message, skip POSIX permission check on Windows
Agent-Logs-Url: https://github.com/github/spec-kit/sessions/4636bcdb-87ae-45d6-9545-a40e4effd617 Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com>
1 parent 9024848 commit ef5deb7

3 files changed

Lines changed: 20 additions & 21 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,6 @@ def _fetch_latest_release_tag() -> tuple[str | None, str | None]:
17211721
On anything else — including a malformed response body — the exception
17221722
propagates; there is no catch-all (research D-006).
17231723
"""
1724-
from .authentication.config import _default_config_path as _auth_config_path
17251724
from .authentication.http import open_url
17261725

17271726
try:
@@ -1739,7 +1738,7 @@ def _fetch_latest_release_tag() -> tuple[str | None, str | None]:
17391738
# Order matters: HTTPError is a subclass of URLError.
17401739
if e.code == 403:
17411740
return None, (
1742-
f"rate limited (configure {_auth_config_path()} with a GitHub token)"
1741+
"rate limited (configure ~/.specify/auth.json with a GitHub token)"
17431742
)
17441743
return None, f"HTTP {e.code}"
17451744
except (urllib.error.URLError, OSError):

src/specify_cli/authentication/config.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from __future__ import annotations
99

1010
import json
11+
import os
1112
import stat
1213
from dataclasses import dataclass
1314
from fnmatch import fnmatch
@@ -53,21 +54,22 @@ def load_auth_config(
5354
if not config_path.is_file():
5455
return []
5556

56-
# Warn (but don't fail) if the file is world-readable.
57-
try:
58-
mode = config_path.stat().st_mode
59-
if mode & (stat.S_IRGRP | stat.S_IROTH):
60-
import warnings
61-
62-
warnings.warn(
63-
f"{config_path} is readable by group/others. "
64-
"Consider restricting with: chmod 600 "
65-
f"{config_path}",
66-
UserWarning,
67-
stacklevel=2,
68-
)
69-
except OSError:
70-
pass # stat failed — skip permission check
57+
# Warn (but don't fail) if the file is world-readable (POSIX only).
58+
if os.name != "nt":
59+
try:
60+
mode = config_path.stat().st_mode
61+
if mode & (stat.S_IRGRP | stat.S_IROTH):
62+
import warnings
63+
64+
warnings.warn(
65+
f"{config_path} is readable by group/others. "
66+
"Consider restricting with: chmod 600 "
67+
f"{config_path}",
68+
UserWarning,
69+
stacklevel=2,
70+
)
71+
except OSError:
72+
pass # stat failed — skip permission check
7173

7274
raw = json.loads(config_path.read_text(encoding="utf-8"))
7375

tests/test_upgrade.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
_normalize_tag,
2424
app,
2525
)
26-
from specify_cli.authentication.config import _default_config_path
27-
2826
from tests.conftest import strip_ansi
2927

3028
runner = CliRunner()
@@ -33,7 +31,7 @@
3331
SENTINEL_GITHUB_TOKEN = "SENTINEL-GITHUB-TOKEN-VALUE"
3432

3533
_RATE_LIMITED_REASON = (
36-
f"rate limited (configure {_default_config_path()} with a GitHub token)"
34+
"rate limited (configure ~/.specify/auth.json with a GitHub token)"
3735
)
3836

3937

@@ -279,7 +277,7 @@ def test_failure_prints_installed_plus_one_line_reason(
279277
assert "Installed: 0.7.4" in output
280278
if expected_reason == _RATE_LIMITED_REASON:
281279
assert "Could not check latest release: rate limited" in output
282-
assert str(_default_config_path()) in output
280+
assert "~/.specify/auth.json" in output
283281
else:
284282
assert f"Could not check latest release: {expected_reason}" in output
285283

0 commit comments

Comments
 (0)