Repository navigation
Fix Internal Error on process pages for logged-out viewers - #34
Merged
Merged
Conversation
Since roles became private for non-public orgs, anonymous viewers can't resolve role references in step text, so ReferenceView fell back to an inline Oops. Oops always rendered a <div>, which inside a markup <p> is invalid HTML; the browser re-parsed it, hydration failed, and SvelteKit showed "Internal Error". - Oops renders a <span> when inline. - Non-members see unresolved references as plain text instead of an error. - The process page queried changes by org id instead of process id, so its Changes section was always empty. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When no role is accountable for a process, the page let anyone logged in edit it, but RLS only allows members of the org. Outsiders saw edit controls whose changes would fail. Require membership, matching RLS. Non-members now see the text the author wrote for an unresolved reference rather than its target. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-hydration # Conflicts: # CHANGELOG
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.
Problem
Logged-out visitors to a public process in a non-public org (e.g.
/org/uwischool/process/TeachingEvaluations) get "Oops… Internal Error".The server render succeeds; the failure is during client hydration:
ReferenceViewfalls back to<Oops inline>, which always rendered a<div>— inside a markup<p>.<div>in<p>is invalid HTML; the browser re-parses it, the DOM no longer matches what Svelte expects, hydration fails, and SvelteKit shows its error page.Members never hit this because their references resolve to links.
Changes
Oops.svelte: render a<span>wheninline(fixes every inline use, includingRoleLink).ReferenceView.svelte: non-members see the text the author wrote for an unresolved reference (the deanin<the dean@Dean>) rather than an error badge; members still see the badge for genuinely broken references.+page.svelte: when no role is accountable for a process, the page let anyone logged in edit it, but RLS only allows members of the org. Outsiders saw edit controls whose changes would fail. It now requires membership, matching RLS.+page.ts:queryProcessChangeswas passed the org id instead of the process id, so the Changes section was always empty.Testing
Reproduced in headless Chromium against production, logged out:
hydration_mismatchthen an uncaught{}(Svelte's hydration sentinel).With the fix, on a local dev server against production data, the page renders with no hydration warnings or errors.
svelte-check: 0 errors. Unit tests: 288 passed.Against the local Supabase stack, using a non-public org with a role
AOMand a public process whose step readsEach year, the <AOM@AOM> notifies faculty. Ask the <bogus@NOPE> for help., I loaded the page in Chromium as each kind of viewer:AOMNOPE(doesn't exist)bogus)bogus)<span>)With
main'sOops/ReferenceView, the same page logsnode_invalid_placement_ssr(<div>inside<p>) andhydration_mismatchfor all three viewers, members included, because of the broken reference. So onmain, members could also hit the crash on any page with a broken reference.Edit controls (title pencil and Delete button), checked on a process with no accountable role and on one owned by
AOM, which the member doesn't hold:AOMaccountablemain)🤖 Generated with Claude Code