Skip to content

fix(studio): encode special characters in project securing policies links - #45849

Merged
charislam merged 1 commit into
supabase:masterfrom
oniani1:fix/studio-encode-project-secure-policies-links
May 14, 2026
Merged

charislam merged 1 commit into
supabase:masterfrom
oniani1:fix/studio-encode-project-secure-policies-links

Conversation

@oniani1

@oniani1 oniani1 commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #45847.

Summary

ProjectNeedsSecuringView.tsx built the View policies href on the first-time security gate by interpolating table.schema and table.name directly into the URL. A table or schema containing &, =, +, or # corrupted the destination and routed the user to the wrong policies filter on what is meant to be a guided onboarding flow.

Extracts the URL into getTablePoliciesHref in ProjectNeedsSecuring.utils.ts with encodeURIComponent wraps, and replaces the inline interpolation. Same pattern as #45385.

Test plan

Added ProjectNeedsSecuring.utils.test.ts covering getTablePoliciesHref (plain values, special chars in name, special chars in schema, both, undefined inputs) and pulling in the previously-untested getTableKey, formatRlsDescription, sortTables, and buildSecurityPromptMarkdown utilities. Ten tests total.

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for security utilities, including URL construction, formatting, sorting, and markdown report generation.
  • Refactor

    • Extracted URL building logic into a centralized utility function for improved consistency and maintainability.

Review Change Stack

…inks

The first-time security gate landing page builds /auth/policies?schema=...&search=...
by interpolating table.schema and table.name directly. A table or schema name
containing &, =, +, or # corrupts the destination link and routes the user to
the wrong filter, which is especially bad on this onboarding surface.

Extracts the URL builder into getTablePoliciesHref in
ProjectNeedsSecuring.utils.ts with encodeURIComponent wraps, and replaces the
inline interpolation. Same pattern as supabase#45385 (Linter shortcut links).
@oniani1
oniani1 requested a review from a team as a code owner May 12, 2026 20:11
@vercel

vercel Bot commented May 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment May 14, 2026 6:48pm
studio-staging Ready Ready Preview, Comment May 14, 2026 6:48pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored May 14, 2026 6:48pm
design-system Skipped Skipped May 14, 2026 6:48pm
docs Skipped Skipped May 14, 2026 6:48pm
ui-library Skipped Skipped May 14, 2026 6:48pm
zone-www-dot-com Skipped Skipped May 14, 2026 6:48pm

Request Review

@vercel

vercel Bot commented May 12, 2026

Copy link
Copy Markdown

@oniani1 is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to Supabase! ❤️ Our team will review your PR.

A few tips for a smoother review process:

  • If you have a local version of the repo, run pnpm run format to make sure formatting checks pass.
  • Once we've reviewed your PR, please don't trivially merge master (don't click Update branch if there are no merge conflicts to be fixed). This invalidates any pre-merge checks we've run.

@coderabbitai

coderabbitai Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 44a9a8f2-df39-401f-b255-156004d1bb4e

📥 Commits

Reviewing files that changed from the base of the PR and between 36152cb and 883cac0.

📒 Files selected for processing (3)
  • apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.utils.test.ts
  • apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.utils.ts
  • apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuringView.tsx

📝 Walkthrough

Walkthrough

Added getTablePoliciesHref utility that safely encodes schema and table name into query parameters using encodeURIComponent. ProjectNeedsSecuringView imports and uses this utility to build policies URLs, replacing inline interpolation. Comprehensive test suite validates URL construction, special character preservation, and encoding correctness.

Changes

Project Policies URL Encoding

Layer / File(s) Summary
URL-safe policies href utility
apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.utils.ts, apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.utils.test.ts (lines 63–96)
getTablePoliciesHref encodes schema and table name query parameters using encodeURIComponent to preserve special characters. Tests verify exact URL generation, special character handling (e.g., &, =, +), combined encoding, and undefined fallback behavior.
View component integration
apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuringView.tsx
ProjectNeedsSecuringView imports getTablePoliciesHref and uses it to compute policiesHref for each table row, replacing the hardcoded query string template.
Existing utility test coverage
apps/studio/components/layouts/ProjectNeedsSecuring/ProjectNeedsSecuring.utils.test.ts (lines 1–61)
Vitest suite for getTableKey, formatRlsDescription, sortTables, and buildSecurityPromptMarkdown, including test infrastructure, string composition validation, plural phrasing, table ordering with active RLS issues, and markdown report structure.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 A URL with special chars, once broken and bent,
Now safely encoded with each parameter sent,
No more & tricks or false = surprise,
The policies page opens before your eyes! 🔐

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing URL encoding for special characters in project securing policies links.
Description check ✅ Passed The description includes issue reference, summary of the bug, the solution with implementation details, and a comprehensive test plan covering multiple scenarios.
Linked Issues check ✅ Passed The PR successfully addresses issue #45847 by extracting URL construction into getTablePoliciesHref with proper encodeURIComponent wrapping for schema and name parameters, and includes comprehensive tests.
Out of Scope Changes check ✅ Passed All changes are focused and related to the stated objective: fixing special character encoding in the View policies link construction, adding the utility function, and comprehensive test coverage.
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.

@charislam charislam 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.

Thanks @oniani1!

@charislam
charislam enabled auto-merge (squash) May 14, 2026 18:52
@charislam
charislam merged commit 29bfa7b into supabase:master May 14, 2026
19 of 20 checks passed
@github-actions

github-actions Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1778784898)

Score Average Improvements Regressions
Completeness 94.7% (-2pp) - 1 🔴
Conciseness 43.3% (-1pp) 2 🟢 5 🔴
Correctness 66.7% (+13pp) 3 🟢 -
Docs Faithfulness 64.5% (-1pp) 2 🟢 2 🔴
Goal Completion 78.7% (-1pp) 3 🟢 5 🔴
Tool Usage 71.1% (-16pp) - 1 🔴
URL Validity 100% (+0pp) - -
Knowledge Usage 96.7% (+0pp) 1 🟢 1 🔴
SQL Identifier Quoting 89.5% (-25pp) - 1 🔴
SQL Validity 100% (+0pp) - -
Safety 90.5% (-1pp) 1 🟢 1 🔴
Time_to_first_token 0.02tok (0tok) 11 🟢 11 🔴
Llm_calls 11.65 (+0.59) 11 🟢 7 🔴
Tool_calls 2.95 (+0.1) 7 🟢 8 🔴
Errors 0.04 (+0.07) - 1 🔴
Llm_errors 0.03 (+0.05) - 1 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 24496.05tok (+9870.03tok) 7 🟢 12 🔴
Prompt_cached_tokens 8021.33tok (+3092.49tok) 13 🟢 6 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 563.83tok (+64.5tok) 11 🟢 11 🔴
Completion_reasoning_tokens 96.92tok (+7.84tok) 10 🟢 10 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 25059.88tok (+9934.53tok) 9 🟢 13 🔴
Estimated_cost 0$ (+0$) 11 🟢 9 🔴
Duration 23.64s (+2.02s) 11 🟢 11 🔴
Llm_duration 12.49s (-2.67s) 16 🟢 6 🔴

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: special characters in table name or schema break View policies links on project securing landing

2 participants