fix(storage): validate types when reading session storage (Closes #144) - #175
Conversation
|
Warning Review limit reached
Next review available in: 39 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Comment |
d964eb9
into
harsharajkumar-273:main
Closes #144
Problem
getSelectedRepotested truthiness, not type:That rejects
''andundefinedbut acceptstrue,42,{}or an array. The value is then returned typed asRepository, and the first consumer to call a string method on it throws —EditorPage.tsx:1057reads it straight into the editor's boot path.sessionStorageis writable by any script on the origin and survives reloads, so a single malformed value wedges the app on every subsequent load until storage is cleared by hand.getTeamSessionwas weaker stillThe issue names both functions, and the second is worth calling out: it checked only
parsed?.repo?.fullName, then copiedparsed.repo.ownerandparsed.repo.nameout completely unexamined. A team session whose repo carried a boolean owner passed validation entirely.Change
A shared
parseRepositoryhelper holds all three repository fields totypeof === 'string' && length > 0, and both entry points use it — so the nested repo inside a team session is validated to the same standard as a standalone one.defaultBranchfalls back to'main'only when it is a non-empty string, rather than on any falsy value. The optional team-session fields are type-checked too:hostNameandhostLoginmust be non-empty strings andcreatedAta finite number, otherwise they come backundefinedrather than passing through whatever was stored.Behaviour for well-formed values is unchanged.
Verification
--strict.Note:
npm run build --prefix frontendcurrently fails on this branch, but for an unrelated pre-existing reason — TS2367 atEditorPage.tsx:3197, which is what my #138 branch fixes. No error is reported inworkspaceStorage.ts. Once #138 lands, the build is clean.