jorgenpt / bichrome

A program that picks which browser & browser profile to open links in based on matching the URL
Apache License 2.0
19 stars 6 forks source link

[ERROR] Encountered error: unable to parse Chrome's Local State #21

Open nathan-nocapinc opened 9 months ago

nathan-nocapinc commented 9 months ago

Appears to be caused by changes in v0.7 related to profiles_by_hosted_domain. I tried adding a bogus hosted_domain to both Chrome profiles but it didn't change anything. Based on the examples that field is supposed to be optional anyways, though.

Please advise if I'm doing something dumb. The config works on v0.6 without any changes.

bichrome.log:

21:54:17 [ERROR] Encountered error: unable to parse Chrome's Local State

Caused by:
    0: could not parse Chrome Local State
    1: missing field `hosted_domain` at line 1 column 6160
21:56:24 [INFO] picked Chrome(ByName { name: "Default" })

bichrome_config.json:

{
    "default_profile": "Personal",
    "profiles": {
        "Personal": {
            "browser": "Chrome",
            "profile": "Default"
        },
        "Work": {
            "browser": "Chrome",
            "profile": "Profile 1"
        }
    },
    "profile_selection": [
        {
            "pattern": "github.com/bungeeapp/*",
            "profile": "Work"
        },
        {
            "pattern": "meet.google.com",
            "profile": "Work"
        },
        {
            "pattern": "localhost",
            "profile": "Personal"
        },
        {
            "pattern": "*.figma.com",
            "profile": "Personal"
        },
        {
            "pattern": "steampowered.com",
            "profile": "Personal"
        },
        {
            "pattern": "linear.app",
            "profile": "Personal"
        }
    ]
}
jorgenpt commented 7 months ago

@nathan-nocapinc I'm using 0.8 on my machine without issue, so it seems like something is unexpected about your particular Chrome's Local State. To debug further I need to know more, but you probably shouldn't share your Local State with me since I suspect it contains personal info.

What I would suggest is that you use something with a JSON formatter (since the file is just one long line) and open up %localappdata%\Google\Chrome\User Data\Local State in it. (I like using VS Code, hitting Ctrl + Shift + P, and using Format Document from that menu.)

In that file, search for info_cache. You should see a JSON list of profiles, and it sounds like at least one of them does not have a"hosted_domain" entry. Can you share that one? Feel free to censor any data like picture URL, name, and id. I created a new empty profile on my machine named "Cakes", and I see this:

            "Profile 2": {
                "active_time": 1713291390.76621,
                "avatar_icon": "chrome://theme/IDR_PROFILE_AVATAR_26",
                "background_apps": false,
                "default_avatar_fill_color": -3282963,
                "default_avatar_stroke_color": -13469302,
                "force_signin_profile_locked": false,
                "gaia_given_name": "",
                "gaia_id": "",
                "gaia_name": "",
                "hosted_domain": "",
                "is_consented_primary_account": false,
                "is_ephemeral": false,
                "is_using_default_avatar": true,
                "is_using_default_name": false,
                "managed_user_id": "",
                "metrics_bucket_index": 3,
                "name": "Cakes",
                "profile_highlight_color": -3282963,
                "shortcut_name": "Cakes",
                "signin.with_credential_provider": false,
                "user_name": ""
            }