Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions scripts/validate-supabase-types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ if [ -z "${SUPABASE_PROJECT_ID:-}" ]; then
echo "⚠️ SUPABASE_PROJECT_ID not set. Type generation might fail if not using local Supabase."
fi

# Early-exit for CI without remote credentials (self-hosted setup).
# The committed src/integrations/supabase/types.ts is the source-of-truth: it's
# generated locally via 'supabase gen types typescript --db-url $SUPABASE_DB_URL'
# (see supabase/config.toml header) and committed to the repo. CI just trusts it.
if [ "${CI:-}" = "true" ] && [ -z "${SUPABASE_PROJECT_ID:-}" ]; then
if [ "$CHECK_MODE" = true ]; then
# check-mode: ensure file is present and non-empty
if [ -f "$TYPES_FILE" ] && [ -s "$TYPES_FILE" ]; then
echo "✅ CI without SUPABASE_PROJECT_ID — committed $TYPES_FILE present (self-hosted setup)."
exit 0
else
echo "❌ Error: $TYPES_FILE missing or empty in CI."
exit 1
fi
else
# gen-mode (prebuild): trust committed file, skip generation
if [ -f "$TYPES_FILE" ]; then
echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)."
exit 0
else
echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set."
Comment on lines +59 to +63
Comment on lines +59 to +63
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if [ -f "$TYPES_FILE" ]; then
echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)."
exit 0
else
echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set."
if [ -f "$TYPES_FILE" ] && [ -s "$TYPES_FILE" ]; then
echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)."
exit 0
else
echo "❌ Error: $TYPES_FILE not found or empty in CI and no SUPABASE_PROJECT_ID set."

GEN_MODE in validate-supabase-types.sh only checks if file exists, not if it's non-empty, allowing empty types.ts to be accepted during CI prebuild

Fix on Vercel

exit 1
Comment on lines +58 to +64
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Evite aceitar types.ts vazio no early-exit de gen-mode

No fluxo de prebuild em CI, o bloco de Line 59 valida só -f. Se types.ts existir mas estiver vazio/corrompido, o script sai com sucesso e pode esconder problema até etapas posteriores. Alinhe com o check-mode exigindo também -s.

Patch sugerido
-    if [ -f "$TYPES_FILE" ]; then
+    if [ -f "$TYPES_FILE" ] && [ -s "$TYPES_FILE" ]; then
       echo "ℹ️  CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)."
       exit 0
     else
-      echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set."
+      echo "❌ Error: $TYPES_FILE missing or empty in CI and no SUPABASE_PROJECT_ID set."
       exit 1
     fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# gen-mode (prebuild): trust committed file, skip generation
if [ -f "$TYPES_FILE" ]; then
echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)."
exit 0
else
echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set."
exit 1
# gen-mode (prebuild): trust committed file, skip generation
if [ -f "$TYPES_FILE" ] && [ -s "$TYPES_FILE" ]; then
echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)."
exit 0
else
echo "❌ Error: $TYPES_FILE missing or empty in CI and no SUPABASE_PROJECT_ID set."
exit 1
fi
🤖 Prompt for 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.

In `@scripts/validate-supabase-types.sh` around lines 58 - 64, The gen-mode
early-exit currently uses a plain -f check against TYPES_FILE which lets an
empty/corrupt types.ts pass; change the condition to test both existence and
non-empty content (use -s "$TYPES_FILE") so the CI prebuild path only succeeds
when TYPES_FILE has size >0. Update the if branch that checks "$TYPES_FILE" (the
gen-mode block) to use -s instead of -f and keep the same success/failure echo
and exit behavior so downstream steps won’t be masked by an empty file.

fi
fi
fi

echo "🔄 Generating Supabase types..."

# Store hash of current file if in check mode
Expand Down
Loading