Skip to content

Conversation

@sofmega
Copy link
Contributor

@sofmega sofmega commented Nov 17, 2025

🔍 Description

This PR validates the relation argument passed to PostgrestClient.from().
Previously, calling:

supabase.from('')

would generate an invalid URL (ending with //) and result in unclear or confusing PostgREST or network errors.
This validation provides clearer developer feedback and avoids silent failures.

What changed?

  • Added a validation check in PostgrestClient.from() to ensure the relation name:
    • is a string
    • is not empty
    • is not only whitespace

If validation fails, the client now throws:

Invalid relation name: relation must be a non-empty string.

Why was this change needed?

Developers frequently make small mistakes such as using an empty string for the relation.
Without validation, this results in unclear and difficult-to-debug errors from downstream fetch calls.

This PR improves DX (developer experience) by catching the issue early and providing a helpful error message.

Closes # (not applicable)


📸 Screenshots/Examples

Before

supabase.from('')
// ❌ Leads to confusing network errors or malformed URLs

After

supabase.from('')
// ❌ Throws: "Invalid relation name: relation must be a non-empty string."

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run npx nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (not applicable)

📝 Additional notes

This enhancement helps prevent silent URL errors, improves developer feedback, and aligns with the existing validation behavior in other Supabase JavaScript client modules.

@sofmega sofmega requested review from a team as code owners November 17, 2025 17:07
@mandarini mandarini merged commit c16602c into supabase:master Nov 19, 2025
24 of 25 checks passed
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