Skip to content

Fix TypeScript compilation and add graceful Supabase client fallbacks in beauty-assistant edge function#113

Merged
Asper Beauty Shop (asperpharma) merged 3 commits into
mainfrom
copilot/fix-typescript-compilation-errors
Mar 5, 2026
Merged

Fix TypeScript compilation and add graceful Supabase client fallbacks in beauty-assistant edge function#113
Asper Beauty Shop (asperpharma) merged 3 commits into
mainfrom
copilot/fix-typescript-compilation-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 5, 2026

The beauty-assistant edge function had TypeScript compilation errors from unresolvable Deno globals/URL imports, and two createClient calls in the website chat path that would crash silently when SUPABASE_SERVICE_ROLE_KEY was absent.

TypeScript fixes (supabase/functions/beauty-assistant/index.ts)

  • declare const Deno — ambient declaration so Deno.env.get() is type-safe without Deno lib types
  • @ts-expect-error on both URL imports (deno.land/std, esm.sh) — resolved at runtime by Supabase Edge, not by tsc

Graceful client creation — website chat path

Replaced non-null assertions with conditional construction, matching the existing webhook-path pattern:

// Before — crashes silently when SUPABASE_SERVICE_ROLE_KEY absent
const serviceClient = createClient(
  Deno.env.get("SUPABASE_URL")!,
  Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!,
);

// After — falls back to anon key, skips entirely if URL unset
const supabaseUrl = Deno.env.get("SUPABASE_URL");
const supabaseKey = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY") ?? Deno.env.get("SUPABASE_ANON_KEY");
if (supabaseUrl && supabaseKey) {
  const productContextClient = createClient(supabaseUrl, supabaseKey);
  // ...
}

Applied to both productContextClient and the adminClient in the campaignSource telemetry block.

New npm scripts + utility scripts

Script Command Purpose
health node scripts/health-check.js Frontend health endpoint check
brain node scripts/brain-check.js Beauty Assistant edge function check (2xx-only success; 401/405 surface misconfiguration)
sync:check node scripts/sync-check.js Concurrent frontend + brain check via res.ok

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: asperpharma <252395498+asperpharma@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix TypeScript compilation issues with Deno URL imports Fix TypeScript compilation and add graceful Supabase client fallbacks in beauty-assistant edge function Mar 5, 2026
@asperpharma Asper Beauty Shop (asperpharma) marked this pull request as ready for review March 5, 2026 14:49
Copilot AI review requested due to automatic review settings March 5, 2026 14:49
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 5, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 11e7767a-074d-4cfd-ac5a-669a1b9d18a2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Signed-off-by: Asper Beauty Shop  <252395498+asperpharma@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

@asperpharma Asper Beauty Shop (asperpharma) merged commit dc9b87a into main Mar 5, 2026
2 checks passed
@asperpharma Asper Beauty Shop (asperpharma) deleted the copilot/fix-typescript-compilation-errors branch March 5, 2026 14:50
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.

3 participants