Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jq error userdata.json:0 #18

Open
flauschxger opened this issue Aug 18, 2023 · 12 comments
Open

jq error userdata.json:0 #18

flauschxger opened this issue Aug 18, 2023 · 12 comments

Comments

@flauschxger
Copy link

Configuration file found, proceeding
jq: error (at /home/mads/.config/kpl/userdata.json:0): Cannot iterate over null (null)
json file successfully populated
jq: error (at /home/mads/.config/kpl/followdata.json:0): Cannot iterate over null (null)
Using monospaced font found kpl config
jq: error (at /home/mads/.config/kpl/followdata.json:0): Cannot iterate over null (null)
jq: error (at /home/mads/.config/kpl/followdata.json:0): Cannot iterate over null (null)

@flauschxger
Copy link
Author

I am on Arch Linux with Xfce 4.18

@jp1995
Copy link
Owner

jp1995 commented Aug 28, 2023

Can you post the contents of your userdata and maybe followdata files after you get this? The followdata file might just be empty, or it might have a new error that I'm not dealing with right now.

@flauschxger
Copy link
Author

Sure,
followdata: {"error":"Bad Request","status":400,"message":"Missing required parameter \"user_id\""}
userdata: {"error":"Unauthorized","status":401,"message":"Invalid OAuth token"}

@jp1995
Copy link
Owner

jp1995 commented Aug 29, 2023

Have you generated your OAuth key and placed it into the config file? It's possible it has expired, too, if it was working for you previously.

It's certainly not supposed to report success in the output there so I'll look into that.

Edit: Yeah, it's strange because when I insert a typo into my OAuth token, it gives me the correct error. There's also a separate error for when the token is missing entirely, which does not appear to be the case for you. I'd try regenerating the token.

@flauschxger
Copy link
Author

Alright will do tomorrow, the token is as old as this issue though. But I will definitely try it out.

Stupid Question but does the token need to be created on the same OS? Because my current token was created on a Windows machine since I can not login to Twitch on Arch, because of Twitch privacy restrictions no browser is working for me. So Kappa Launcher is also the current best alternative for a smooth experience.

@flauschxger
Copy link
Author

Alright, had some irl stuff to do, so I could only just do it. I replaced the OAuth token with a new one, but the same issue persists. I tried to write a faulty OAuth key on purpose but that just kept the same error, but instead of 3 times, just 1 time.

@jp1995
Copy link
Owner

jp1995 commented Sep 7, 2023

Sorry for the late reply, missed your comment. Have you done a full config wipe and reinstall yet? I'm quite perplexed about this issue you're getting, as I can't really replicate it.

@flauschxger
Copy link
Author

Yes I did, I also completely clean built and deleted the config folder beforehand. Is there any Rust configuration you have?

@flauschxger
Copy link
Author

sorry, I meant rofi not rust

@flauschxger
Copy link
Author

It's an jq error, I am not an expert but I will try looking into it myself, maybe this helps

@flauschxger
Copy link
Author

flauschxger commented Sep 7, 2023

I manged to fix it myself by adding

Check if userdata.json exists and is not empty

if [ ! -s "$MAIN_PATH/userdata.json" ]; then
    echo "ERROR: userdata.json is empty or does not exist."
    exit 1
fi

Check if followdata.json exists and is not empty

if [ ! -s "$MAIN_PATH/followdata.json" ]; then
    echo "ERROR: followdata.json is empty or does not exist."
    exit 1
fi

Check if userdata.json contains valid data

USER_ID=$(jq -r '.data[].id' $MAIN_PATH/userdata.json)
if [ -z "$USER_ID" ]; then
    echo "ERROR: userdata.json does not contain valid data."
    exit 1
fi

Check if followdata.json contains valid data

if ! jq -e '.data | length > 0' $MAIN_PATH/followdata.json >/dev/null; then
    echo "ERROR: followdata.json does not contain valid data."
    exit 1
fi 

Between the populate check and the call for names of live channels, then delete followdata.json and userdata.json and let them repopulate.

@ahmetkotanci
Copy link

ahmetkotanci commented Jun 11, 2024

I manged to fix it myself by adding

Check if userdata.json exists and is not empty

if [ ! -s "$MAIN_PATH/userdata.json" ]; then
    echo "ERROR: userdata.json is empty or does not exist."
    exit 1
fi

Check if followdata.json exists and is not empty

if [ ! -s "$MAIN_PATH/followdata.json" ]; then
    echo "ERROR: followdata.json is empty or does not exist."
    exit 1
fi

Check if userdata.json contains valid data

USER_ID=$(jq -r '.data[].id' $MAIN_PATH/userdata.json)
if [ -z "$USER_ID" ]; then
    echo "ERROR: userdata.json does not contain valid data."
    exit 1
fi

Check if followdata.json contains valid data

if ! jq -e '.data | length > 0' $MAIN_PATH/followdata.json >/dev/null; then
    echo "ERROR: followdata.json does not contain valid data."
    exit 1
fi 

Between the populate check and the call for names of live channels, then delete followdata.json and userdata.json and let them repopulate.

hi where did you add these. Im getting exact same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants