From db9d97bcbda5eedfed83f7ccf93bc1e2c1c79795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Den=20Delimarsky=20=F0=9F=8C=BA?= <53200638+localden@users.noreply.github.com> Date: Sat, 20 Sep 2025 08:46:32 -0700 Subject: [PATCH 1/2] Update __init__.py --- src/specify_cli/__init__.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.py index 891d5f2e9..27ce122c4 100644 --- a/src/specify_cli/__init__.py +++ b/src/specify_cli/__init__.py @@ -53,17 +53,13 @@ ssl_context = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT) client = httpx.Client(verify=ssl_context) def _github_token(cli_token: str | None = None) -> str | None: - return cli_token or os.getenv("GH_TOKEN") or os.getenv("GITHUB_TOKEN") + """Return sanitized GitHub token (cli arg takes precedence) or None.""" + return ((cli_token or os.getenv("GH_TOKEN") or os.getenv("GITHUB_TOKEN") or "").strip()) or None def _github_auth_headers(cli_token: str | None = None) -> dict: - """Headers for GitHub REST API requests. - - Uses Bearer auth if token present - """ - headers = {} + """Return Authorization header dict only when a non-empty token exists.""" token = _github_token(cli_token) - if token: - headers["Authorization"] = f"Bearer {token}" - return headers + return {"Authorization": f"Bearer {token}"} if token else {} # Constants AI_CHOICES = { @@ -447,7 +443,7 @@ def download_template_from_github(ai_assistant: str, download_dir: Path, *, scri api_url, timeout=30, follow_redirects=True, - headers=_github_auth_headers(github_token) or None, + headers=_github_auth_headers(github_token), ) status = response.status_code if status != 200: @@ -500,7 +496,7 @@ def download_template_from_github(ai_assistant: str, download_dir: Path, *, scri download_url, timeout=60, follow_redirects=True, - headers=_github_auth_headers(github_token) or None, + headers=_github_auth_headers(github_token), ) as response: if response.status_code != 200: body_sample = response.text[:400] From fbacd0b0df3cfe8dd3395af92bb6a978a4117036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Den=20Delimarsky=20=F0=9F=8C=BA?= <53200638+localden@users.noreply.github.com> Date: Sat, 20 Sep 2025 08:49:44 -0700 Subject: [PATCH 2/2] Update version rev --- CHANGELOG.md | 8 +++++++- pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42d02b122..91bea6311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to the Specify CLI will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.10] - 2025-09-20 + +### Fixed + +- Addressed [#378](https://github.com/github/spec-kit/issues/378) where a GitHub token may be attached to the request when it was empty. + ## [0.0.9] - 2025-09-19 ### Changed @@ -16,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Windsurf IDE support as additional AI assistant option -- GitHub token support for API requests to handle corporate environments and rate limiting (contributed by @zryfish in #243) +- GitHub token support for API requests to handle corporate environments and rate limiting (contributed by [@zryfish](https://github.com/@zryfish) in [#243](https://github.com/github/spec-kit/pull/243)) ### Changed diff --git a/pyproject.toml b/pyproject.toml index f5853a7b2..bac191094 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "specify-cli" -version = "0.0.9" +version = "0.0.10" description = "Specify CLI, part of GitHub Spec Kit. A tool to bootstrap your projects for Spec-Driven Development (SDD)." requires-python = ">=3.11" dependencies = [