Skip to content

fix: make supabase service key env var consistent#2867

Open
pranayukey200 wants to merge 1 commit into
ritesh-1918:mainfrom
pranayukey200:fix/2823-inconsistent-supabase-env-var
Open

fix: make supabase service key env var consistent#2867
pranayukey200 wants to merge 1 commit into
ritesh-1918:mainfrom
pranayukey200:fix/2823-inconsistent-supabase-env-var

Conversation

@pranayukey200

@pranayukey200 pranayukey200 commented Jun 14, 2026

Copy link
Copy Markdown

Fix: Make Supabase service key environment variable consistent This PR fixes the inconsistent environment variable naming for the Supabase service key:

  1. Updated all files using SUPABASE_SERVICE_ROLE_KEY to use SUPABASE_SERVICE_KEY (matching .env.example)
  2. Added backward compatibility by falling back to SUPABASE_SERVICE_ROLE_KEY if SUPABASE_SERVICE_KEY isn't available
  3. Updated files: auto_close_service.py , notification_routing.py , and seed_company_settings.py

closes #2823

Summary by CodeRabbit

  • Chores
    • Enhanced backend service authentication configuration for improved system reliability.

@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

@pranayukey200 is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Three backend files are updated to resolve an env var naming inconsistency: Supabase client initialization in auto_close_service.py, notification_routing.py, and seed_company_settings.py (two sites) now reads SUPABASE_SERVICE_KEY first, falling back to SUPABASE_SERVICE_ROLE_KEY.

Changes

Supabase service key env var normalization

Layer / File(s) Summary
Service key env var fallback
backend/services/auto_close_service.py, backend/services/notification_routing.py, backend/scripts/seed_company_settings.py
All four Supabase client initialization sites updated to prefer SUPABASE_SERVICE_KEY with a fallback to SUPABASE_SERVICE_ROLE_KEY, matching the key name declared in .env.example.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • ritesh-1918/HELPDESK.AI#1989: Applies the same SUPABASE_SERVICE_KEY / SUPABASE_SERVICE_ROLE_KEY fallback fix to the same three files.
  • ritesh-1918/HELPDESK.AI#2022: Also adds env-var aliasing for the Supabase service key in seed_company_settings.py, auto_close_service.py, and notification_routing.py.
  • ritesh-1918/HELPDESK.AI#2475: Directly applies the same SUPABASE_SERVICE_KEY-first selection fix across the same set of files.

Suggested labels

type:bug, level:intermediate, quality:clean

Poem

🐇 A bunny once tripped on a key mismatch tale,
SERVICE_KEY and ROLE_KEY both left in the trail.
Now or saves the day with a fallback so neat,
The seed script and services no longer retreat.
Consistent config — the warren's complete! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: making Supabase service key environment variable naming consistent across the backend codebase.
Linked Issues check ✅ Passed The PR successfully addresses issue #2823 by updating all three affected files to use SUPABASE_SERVICE_KEY with fallback to SUPABASE_SERVICE_ROLE_KEY for backward compatibility.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the environment variable inconsistency; no out-of-scope modifications were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/services/auto_close_service.py`:
- Around line 37-40: Add explicit validation before calling create_client(...)
to ensure both SUPABASE_URL and the resolved Supabase key (with fallback from
SUPABASE_SERVICE_KEY or SUPABASE_SERVICE_ROLE_KEY) are not None. In
backend/services/auto_close_service.py#L37-L40, validate both credentials and
raise/log a clear service-specific error if either is missing before passing to
create_client. In backend/services/notification_routing.py#L54-L57, apply the
same validation guard with middleware-startup-specific error handling. In
backend/scripts/seed_company_settings.py#L48-L51, validate credentials before
seeding client creation and return an actionable error status if env is
incomplete. In backend/scripts/seed_company_settings.py#L142-L145, extract the
validation logic into a reusable helper and use it in verify_seed() to ensure
consistent validation behavior with seed_company_settings().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aab13cdd-7fa4-417f-a76c-6d9e76af80cf

📥 Commits

Reviewing files that changed from the base of the PR and between da8faf2 and a9f9359.

📒 Files selected for processing (3)
  • backend/scripts/seed_company_settings.py
  • backend/services/auto_close_service.py
  • backend/services/notification_routing.py

Comment thread backend/services/auto_close_service.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Inconsistent environment variable naming (SUPABASE_SERVICE_ROLE_KEY vs SUPABASE_SERVICE_KEY)

1 participant