fix: remove hardcoded Supabase service-role JWT (#3) #42
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-card-creation#42
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-card-creation-3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #3
Summary
service_roleJWT fromscripts/supabase_doodling.pyos.environ["SUPABASE_SERVICE_ROLE_KEY"]lookup; the script will raiseKeyErrorat startup if the env var is missing (fail-fast, no silent fallback)Authorizationandapikeyheaders now reference the same env varFiles changed
scripts/supabase_doodling.py— credentials removed,import osaddedNotes
The key was a Supabase
service_roleJWT (bypasses RLS). It should be rotated in the Supabase dashboard after this PR merges. The token expiry in the JWT payload is 2061, so it remains active until rotated.Other observations
params: list = Noneshould beOptional[list](pre-existing type hint issue)log_exceptioncall signature, unusedtimeoutparam) — out of scope for this fixAI Code Review
Files Reviewed
scripts/supabase_doodling.py(modified)Findings
Correctness
Authorizationandapikeyheaders previously used the same hardcoded JWT value; both now reference the same_SUPABASE_KEYvariable — behaviorally identical, minus the credential exposure._SUPABASE_KEY = os.environ["SUPABASE_SERVICE_ROLE_KEY"]) means any import of this module will fail immediately withKeyErrorif the env var is absent. This is the intended fail-fast behaviour described in the PR.DB_URLstill contains the Supabase project reference ID (cnphpnuvhjvqzkcbwzdk) — this is not a secret (it appears in every API request URL) and leaving it hardcoded is fine.Security
service_roleJWT (which bypasses Row Level Security) is no longer stored in source. This is the correct fix.Style & Conventions
import osplacement: added beforefrom typing import Literal— standard library imports should come first per PEP 8, so this order (os→typing→ third-party) is correct.params: list = None, wronglog_exceptionsignature, unusedtimeout) are correctly called out in the PR body as out of scope.Suggestions
os.environ.get("SUPABASE_SERVICE_ROLE_KEY")with an explicitraise EnvironmentError(...)for a more descriptive error message than a bareKeyError, but this is a minor UX-only improvement — the current fail-fast approach is perfectly acceptable.Verdict: COMMENT (LGTM)
Clean security fix. The credential removal is correct, both headers are consistently updated, and the fail-fast env var lookup is the right pattern. Merge when the Supabase key rotation is ready.
Automated review by Claude PR Reviewer
Pull request closed