Skip to content

Commit 0ea4fd1

Browse files
ImTotemclaude
andcommitted
fix(config): validate JWT_SECRET at startup instead of type: ignore
- jwt_secret defaults to "" (satisfies pyright) - create_app() raises RuntimeError if JWT_SECRET is empty Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d93fd29 commit 0ea4fd1

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/bcsd_api/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class Settings(BaseSettings):
55
google_client_id: str = ""
6-
jwt_secret: str
6+
jwt_secret: str = ""
77
jwt_algorithm: str = "HS256"
88
jwt_expire_minutes: int = 1440
99
google_sheets_id: str = ""

src/bcsd_api/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@lru_cache
1616
def get_settings() -> Settings:
17-
return Settings() # type: ignore[call-arg]
17+
return Settings()
1818

1919

2020
@lru_cache

src/bcsd_api/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def create_app() -> FastAPI:
4848
redoc_url=None,
4949
)
5050
settings = get_settings()
51+
if not settings.jwt_secret:
52+
raise RuntimeError("JWT_SECRET is required in .env")
5153
from . import slack_log
5254
slack_log.setup(settings.slack_bot_token, settings.slack_error_channel)
5355
app.add_middleware(

0 commit comments

Comments
 (0)