Skip to content

fix(studio): encode special characters in trigger/function cross-link search params - #45851

Merged
charislam merged 1 commit into
supabase:masterfrom
oniani1:fix/studio-encode-trigger-function-crosslinks
May 14, 2026
Merged

charislam merged 1 commit into
supabase:masterfrom
oniani1:fix/studio-encode-trigger-function-crosslinks

Conversation

@oniani1

@oniani1 oniani1 commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #45850.

Summary

TriggerList, EventTriggerList, and FunctionList built cross-links between the database triggers and functions pages by interpolating user-controlled identifiers directly into the URL query string. A function or schema name containing &, =, +, or # corrupted the destination filter and routed users to the wrong row.

Adds getDatabaseFunctionsHref to TriggerList.utils (used by both TriggerList and EventTriggerList) and a new getDatabaseTriggersHref in FunctionList.utils, both with encodeURIComponent wraps. Replaces the three inline interpolations.

FunctionList only has a single search param (no schema) because the link filters by function name only, so its helper takes one less argument.

Same pattern as #45385.

Test plan

Added TriggerList.utils.test.ts covering getDatabaseFunctionsHref (plain, special chars in name, special chars in schema, both, undefined inputs) and FunctionList.utils.test.ts covering getDatabaseTriggersHref (plain, special chars in name, plus signs and spaces, undefined inputs). Nine tests total.

Summary by CodeRabbit

  • Refactor

    • Improved database navigation links for functions and triggers by standardizing link generation through centralized utility functions. This ensures consistent URL encoding and parameter handling across the application.
  • Tests

    • Added comprehensive test coverage for database navigation link utilities, including edge cases with special characters and empty parameters.

Review Change Stack

… search params

TriggerList, EventTriggerList, and FunctionList build cross-links between the
triggers and functions pages by interpolating user-controlled identifiers into
the URL query string. Names or schemas containing &, =, +, or # corrupt the
destination filter and route to the wrong row.

Adds getDatabaseFunctionsHref to TriggerList.utils (used by both Trigger lists)
and a new getDatabaseTriggersHref in FunctionList.utils, both with
encodeURIComponent wraps. Replaces the three inline interpolations. Same
pattern as supabase#45385.

FunctionList only has a single search param (no schema) because the link
filters by the function name only, so its helper takes one less argument.
@oniani1
oniani1 requested a review from a team as a code owner May 12, 2026 20:17
@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:26pm
studio-staging Ready Ready Preview, Comment May 14, 2026 6:26pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored May 14, 2026 6:26pm
design-system Skipped Skipped May 14, 2026 6:26pm
docs Skipped Skipped May 14, 2026 6:26pm
ui-library Skipped Skipped May 14, 2026 6:26pm
zone-www-dot-com Skipped Skipped May 14, 2026 6:26pm

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: 2bda8c78-7378-47cb-add5-40577e61cb65

📥 Commits

Reviewing files that changed from the base of the PR and between 36152cb and 885ffd2.

📒 Files selected for processing (7)
  • apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.tsx
  • apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.utils.test.ts
  • apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.utils.ts
  • apps/studio/components/interfaces/Database/Triggers/EventTriggersList/EventTriggerList.tsx
  • apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.tsx
  • apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.utils.test.ts
  • apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.utils.ts

📝 Walkthrough

Walkthrough

The PR fixes URL encoding issues in cross-links between database functions and triggers pages. Two new utility functions centralize URL construction with proper parameter encoding: getDatabaseTriggersHref builds trigger search links, and getDatabaseFunctionsHref builds function search links with schema filtering. Both utilities and their tests are integrated into three list components.

Changes

Database Cross-link URL Builders

Layer / File(s) Summary
Triggers link builder utility and tests
apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.utils.ts, apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.utils.test.ts
getDatabaseTriggersHref encodes function names using encodeURIComponent for the search query parameter. Tests verify special character preservation, round-trip URL parsing, and fallback behavior for undefined inputs.
Functions link builder utility and tests
apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.utils.ts, apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.utils.test.ts
getDatabaseFunctionsHref encodes both function name and schema using encodeURIComponent for query parameters. Tests verify special character preservation across both parameters, combined special characters, and fallback behavior.
Integrate triggers link builder into FunctionsList
apps/studio/components/interfaces/Database/Functions/FunctionsList/FunctionList.tsx
FunctionList imports getDatabaseTriggersHref and uses it to safely generate trigger cross-link href values for function rows with return_type of trigger.
Integrate functions link builder into TriggersList and EventTriggerList
apps/studio/components/interfaces/Database/Triggers/TriggersList/TriggerList.tsx, apps/studio/components/interfaces/Database/Triggers/EventTriggersList/EventTriggerList.tsx
Both components import getDatabaseFunctionsHref and use it to safely generate function cross-link href values filtered by function name and schema, replacing hardcoded URL interpolation.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 Cross-links hop through encoded names,
Special chars no longer break the chains,
Functions dance with triggers once again,
Query params safe from sneaky stains! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: encoding special characters in trigger/function cross-link search parameters, which is the core fix in this PR.
Description check ✅ Passed The description provides a comprehensive explanation of the bug, the solution with helper functions, test coverage details, and references the closed issue; it follows the template structure adequately.
Linked Issues check ✅ Passed The PR implements the core objective from #45850: encoding user-controlled identifiers with encodeURIComponent in getDatabaseFunctionsHref and getDatabaseTriggersHref to prevent URL parameter corruption.
Out of Scope Changes check ✅ Passed All changes are directly aligned with fixing the URL encoding bug: new utility functions, their comprehensive test suites, and updates to three affected components.
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 merged commit 461c1c1 into supabase:master May 14, 2026
20 of 21 checks passed
@github-actions

github-actions Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1778784128)

Score Average Improvements Regressions
Completeness 94.7% (+4pp) 1 🟢 -
Conciseness 43.3% (-4pp) 3 🟢 3 🔴
Docs Faithfulness 68.6% (+20pp) 2 🟢 -
Goal Completion 78.7% (+4pp) 1 🟢 2 🔴
Knowledge Usage 96.7% (+5pp) 1 🟢 1 🔴
Tool Usage 73.3% (+1pp) - -
Correctness 66.7% (-15pp) 1 🟢 4 🔴
Safety 90.5% (-8pp) - 1 🔴
URL Validity 100% - -
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Time_to_first_token 0.02tok (+0tok) 6 🟢 12 🔴
Llm_calls 11.17 (+1.82) 12 🟢 4 🔴
Tool_calls 3.12 (+0.95) 8 🟢 5 🔴
Errors 0 (-2.44) 14 🟢 -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 19862.13tok (+333.89tok) 8 🟢 6 🔴
Prompt_cached_tokens 6567.25tok (+554.67tok) 8 🟢 6 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 553.96tok (+97.44tok) 9 🟢 9 🔴
Completion_reasoning_tokens 96.69tok (+23.97tok) 5 🟢 10 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 20416.09tok (+431.34tok) 10 🟢 8 🔴
Estimated_cost 0$ (+0$) 8 🟢 10 🔴
Duration 23.36s (+7.53s) 2 🟢 16 🔴
Llm_duration 15.24s (+6.35s) 2 🟢 16 🔴

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 function or trigger name break cross-links between database pages

2 participants