Skip to content

Fix build for missing Supabase env vars#35

Open
wiatrM wants to merge 1 commit into
mainfrom
qcicq0-codex/investigate-503-error-after-merge
Open

Fix build for missing Supabase env vars#35
wiatrM wants to merge 1 commit into
mainfrom
qcicq0-codex/investigate-503-error-after-merge

Conversation

@wiatrM

@wiatrM wiatrM commented Jul 4, 2025

Copy link
Copy Markdown
Member

Summary

  • handle missing Supabase credentials during build
  • allow blog service to skip Supabase calls when not configured
  • guard auth service and context against missing Supabase
  • show message in SupabaseConnectionTest when Supabase isn't configured

Testing

  • npm run lint
  • npm run build
  • npm test
  • npm run test:e2e (fails: WebServer warnings, ended manually)
  • npm run test:a11y (fails: missing script)

https://chatgpt.com/codex/tasks/task_e_6868147445088325b02768260de8b28e

Copilot AI review requested due to automatic review settings July 4, 2025 19:37
@wiatrM wiatrM requested a review from Sebastian-Debicki as a code owner July 4, 2025 19:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces fallbacks and guards around missing Supabase environment variables to prevent build and runtime errors when Supabase is unconfigured.

  • Provide placeholder URL/anon key and expose isSupabaseConfigured flag.
  • Guard client/server creation and service methods (blog & auth) to skip Supabase calls.
  • Update context and test component to handle and display missing Supabase config.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/supabase/client.ts Added placeholder env defaults, isSupabaseConfigured, and guard in createServerClient.
lib/services/blog.service.ts Early-return branches when Supabase is unconfigured with console warnings.
lib/auth/auth.service.ts Added config checks in each auth method and default behavior in onAuthStateChange.
contexts/AuthContext.tsx Wraps auth-state subscription in isSupabaseConfigured check.
components/SupabaseConnectionTest.tsx Shows error message if Supabase isn’t configured before testing.
Comments suppressed due to low confidence (2)

components/SupabaseConnectionTest.tsx:12

  • We should add unit or integration tests for the branch where Supabase isn’t configured to verify that the component shows the error state as expected.
      if (!isSupabaseConfigured) {

lib/auth/auth.service.ts:224

  • The fallback return of { data: null } in onAuthStateChange doesn’t include a subscription property, which consumers expect. Consider returning { data: { subscription: null } } for a consistent interface.
    if (!isSupabaseConfigured) {


// Get posts with filtering and pagination
async getPosts(params: BlogSearchParams = {}): Promise<BlogPaginatedResponse> {
if (!isSupabaseConfigured) {

Copilot AI Jul 4, 2025

Copy link

Choose a reason for hiding this comment

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

There's a lot of repeated if (!isSupabaseConfigured) boilerplate across service methods. Consider extracting this pattern into a higher-order function or wrapper to reduce duplication and improve readability.

Copilot uses AI. Check for mistakes.
Comment thread lib/supabase/client.ts
if (!isSupabaseConfigured) {
throw new Error('Supabase environment variables are not configured')
}
return createClient<Database>(supabaseUrl!, supabaseAnonKey!)

Copilot AI Jul 4, 2025

Copy link

Choose a reason for hiding this comment

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

The non-null assertions (!) on supabaseUrl and supabaseAnonKey are redundant since they always have a fallback string value. You can remove the ! operators.

Suggested change
return createClient<Database>(supabaseUrl!, supabaseAnonKey!)
return createClient<Database>(supabaseUrl, supabaseAnonKey)

Copilot uses AI. Check for mistakes.
@wiatrM wiatrM closed this Jul 5, 2025
@wiatrM wiatrM reopened this Jul 5, 2025
@wiatrM wiatrM closed this Jul 5, 2025
@wiatrM wiatrM reopened this Jul 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants