Bug: Extension throws an error when setting color preference if user is not logged in to GitHub #240
Closed
2 tasks done
Labels
🐛 bug
Something isn't working
good first issue
Good for newcomers
👀 needs triage
released on @beta
released
Describe the bug
I came across this while investigating #237
When navigating to GitHub.com and you are not logged in to GitHub.com, the browser extension throws an error in the browser DevTools console.
Steps to reproduce
The issue is the cookie does not contain
color_mode
if you are logged out.logged out cookie contents:
'_octo=GH1.1.693368319.1691169597; preferred_color_mode=light; tz=America%2FToronto'
logged in cookie contents
'_octo=GH1.1.614461846.1691070766; color_mode=%7B%22color_mode%22%3A%22auto%22%2C%22light_theme%22%3A%7B%22name%22%3A%22light%22%2C%22color_mode%22%3A%22light%22%7D%2C%22dark_theme%22%3A%7B%22name%22%3A%22light%22%2C%22color_mode%22%3A%22light%22%7D%7D; preferred_color_mode=light; tz=America%2FToronto'
The issue is the code always assumes that the regex match is always succesful.
A small tweak to the code for color preference will fix this. See https://github.com/open-sauced/ai/blob/7ad0fdfe18ae1fe140582932bfc885716c0da729/src/utils/colorPreference.ts
Browsers
No response
Additional context (Is this in dev or production?)
No response
Code of Conduct
Contributing Docs
The text was updated successfully, but these errors were encountered: