Fix Projects page crash for project names with colons/slashes (#1414)#1475
Open
JoeJoeflyn wants to merge 1 commit into
Open
Fix Projects page crash for project names with colons/slashes (#1414)#1475JoeJoeflyn wants to merge 1 commit into
JoeJoeflyn wants to merge 1 commit into
Conversation
Contributor
Greptile SummaryThis PR fixes project routes for names with URL-unsafe characters. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. The change is narrow, keeps Rails/Inertia route-helper usage, and includes targeted tests for the affected unsafe-name flows. No files require special attention.
What T-Rex did
Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant ProjectsUI as Projects Svelte UI
participant Routes as js_from_routes helper
participant Rails as Rails Projects routes
User->>ProjectsUI: Open card/archive/share action
ProjectsUI->>ProjectsUI: encodeURIComponent(projectName)
ProjectsUI->>Routes: Build path with encoded projectName
Routes-->>ProjectsUI: "Return /my/projects/<encoded-name>"
ProjectsUI->>Rails: Navigate or PATCH encoded path
Rails->>Rails: Decode path param
Rails-->>ProjectsUI: Render/update original project name
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant ProjectsUI as Projects Svelte UI
participant Routes as js_from_routes helper
participant Rails as Rails Projects routes
User->>ProjectsUI: Open card/archive/share action
ProjectsUI->>ProjectsUI: encodeURIComponent(projectName)
ProjectsUI->>Routes: Build path with encoded projectName
Routes-->>ProjectsUI: "Return /my/projects/<encoded-name>"
ProjectsUI->>Rails: Navigate or PATCH encoded path
Rails->>Rails: Decode path param
Rails-->>ProjectsUI: Render/update original project name
Reviews (1): Last reviewed commit: "Fix Projects page crash for project name..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the problem
Project names containing colons followed by a letter (e.g.
myproject:R) crash the Projects page — the card list fails to render and cards appear/disappear at random. Mentioned in #1414.Root cause:
js-from-routes'interpolateUrldoes raw string replacement of:paramNamein route templates. After substitutingmyproject:Rinto/my/projects/:project_name, the leftover:Rmatches itsREQUIRED_PARAMETER = /:[^\W\d]+/gregex, so it throwsTypeError: Missing URL Parameter :R. Because the cards render inside aWindowVirtualizer, one card's throw breaks the entire list.Same family as #1442 (slash
/in project name → 400 on archive).Describe your changes
URL-encode the project name with
encodeURIComponent()before passing it tojs_from_routes' path helpers. The colon becomes%3A, whichinterpolateUrlno longer misreads as a route parameter. Rails decodes%3Aback to:when matching the route, so the controller receives the original name and everything works — the card stays clickable, the detail page loads, archive works.Three files changed (all frontend, one-line pattern each):
ProjectCard.svelte— encode beforeshow.path()andupdate.path(), wrapped in try/catch as defense-in-depth so any future edge case degrades to "no link" on one card instead of nuking the whole virtualizerIndex.svelte— encode for archive/unarchive pathShareModal.svelte— encode for toggle_share pathNo Ruby changes — Rails already decodes path params, so the controller receives the original name.
Screenshots / Media
Before: project named
myproject:R→ Projects page cards fail to render (crash ininterpolateUrl).After: same project → card renders normally, clickable, navigates to detail page at
/my/projects/myproject%3AR, archive works.Test plan
test/system/projects_with_unsafe_names_test.rb— 4 tests, 43 assertions)?,#,%, unicode, normal)/returns a 400 error #1442)/returns a 400 error #1442)bundle exec rubocopclean on changed filessvelte-check— 0 errors in changed filesRelated: #1414, #1442
screenrecording-2026-07-21_00-25-16.mp4