Skip to content

fix(auth): load KEY_HMAC_SECRET via pydantic settings#22

Merged
Shaivpidadi merged 3 commits into
devfrom
feat/fix-key-hmac-secret-settings
Apr 23, 2026
Merged

fix(auth): load KEY_HMAC_SECRET via pydantic settings#22
Shaivpidadi merged 3 commits into
devfrom
feat/fix-key-hmac-secret-settings

Conversation

@Shaivpidadi

Copy link
Copy Markdown
Member

Summary

  • KEY_HMAC_SECRET was read from os.environ at module import time in key_utils.py, before pydantic-settings had a chance to load .env
  • This caused a RuntimeError on any authenticated endpoint when running locally
  • Fix: move key_hmac_secret into the Settings model (pydantic-settings loads it correctly from .env or env vars), read it lazily per-call in _hmac_secret()

Test

  • Health: x-request-id and x-response-time-ms headers present ✅
  • Precheck: authenticates correctly, returns 422 on bad payload (not 500) ✅

Refs: dad49415-dc61-41a5-b1c6-a013d156ee0a
@Shaivpidadi
Shaivpidadi merged commit 96d1b0d into dev Apr 23, 2026
4 checks passed
@Shaivpidadi
Shaivpidadi deleted the feat/fix-key-hmac-secret-settings branch April 23, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant