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

Unexpected token E in JSON at position 0 #186

Open
akshitcompro opened this issue Mar 28, 2024 · 16 comments
Open

Unexpected token E in JSON at position 0 #186

akshitcompro opened this issue Mar 28, 2024 · 16 comments

Comments

@akshitcompro
Copy link

We are facing the below error on using @electron/notarize v2.3.0

image

Not sure, what's the actual issue here. We are providing all the required params to the notarize function:

image
@Chamarsh
Copy link

Having the same issue

@rotu
Copy link
Contributor

rotu commented Mar 28, 2024

This is the same issue as #177.

@yingchen-liu
Copy link

Same here

@yingchen-liu
Copy link

Looks like it is trying to parse a JSON that is not actually a JSON. notarytool returns a string instead of JSON when there is an error occurs.
I modified the node_modules/@electron/notarize/lib/notarytool.js file to make it throw an error with the JSON string, so that I can see the actual error message from Apple.

const result = yield (0, spawn_1.spawn)('xcrun', notarizeArgs);

throw new Error(result.output.trim());

const parsed = JSON.parse(result.output.trim());

For me the error is "Error: HTTP status code: 403. Invalid or inaccessible developer team ID for the provided Apple ID. Ensure the Team ID is correct and that you are a member of that team."

@andelf
Copy link

andelf commented Apr 10, 2024

Turned out that you need to sign some new agreement on Apple Developer site.

@rotu
Copy link
Contributor

rotu commented Apr 10, 2024

Turned out that you need to sign some new agreement on Apple Developer site.

That may have been the case for you, but there are many other reasons the command can print non-JSON output.

@EternallLight
Copy link

Strangely, it still fails for me when using the plugin as is.

This change in node_modules/@electron/notarize/lib/notarytool.js magically fixes it for me:

            const result = yield (0, spawn_1.spawn)('xcrun', notarizeArgs);
            console.log('Attempting to parse that crap:', result.output.trim());
            let parsed;
            try {
                parsed = JSON.parse(result.output.trim());
            } catch (e) {
                console.error("Failed to parse JSON:", e);
                throw new Error(result.output.trim());
            }

@warrenday
Copy link

Had the same issue, currently forking the repo to apply the above fix.

@therockerline
Copy link

Good morning, i have the same problem. i run notarize on a gitaction. when i am on local i have no problem but when the operation is run on GitHub instead i get that error message. I tried to fork the library and added the fix of 'EternallLight' but it doesn't seem to be used. Any advice?

@warrenday
Copy link

Rollback to version 2.2.0 where JSON is parsed correctly.

"@electron/notarize": "2.2.0"

Also be sure to add resolutions to your package.json so your other electron packages use the correct version.

"resolutions": {
"@electron/notarize": "2.2.0"
}

@therockerline
Copy link

Ok, with the rollback to 2.2.0 the error has changed. now it says "Error: HTTP status code: 401. Not authenticated. Make sure all authentication arguments are correct." but when I run notarize locally everything is fine. The problem occurs only on gitactions. I use the three environment variables:

APPLE_API_KEY: ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8
APPLE_API_KEY_ID: ${{ secrets.api_key_id }}
APPLE_API_ISSUER: ${{ secrets.api_key_issuer_id }}

@cpvalente
Copy link

Turned out that you need to sign some new agreement on Apple Developer site.

Hi @andelf, can you provide more feedback as to what was missing?

@remloyal
Copy link

remloyal commented May 7, 2024

I am encountering the same problem. May I ask if there is any way to solve it?

@cpvalente
Copy link

I have encountered this issue in my attempts. Leaving this here as it may help someone else.

The error for me happened when the notarize function tried to parse the response from the initial request.
In my case, it ended up being an issue with authentication as my Apple ID was wrong, so it return an error message ( Error: HTTP status code: 401. Invalid credentials... hence the start with E)

I guess electron-notarize could be more helpful in providing a better error as suggested in #191

@austinlangdon
Copy link

Turned out that you need to sign some new agreement on Apple Developer site.

Thank you

I was also able to fix this by logging into my Apple Developer account and accepting the updated agreement.

@rotu
Copy link
Contributor

rotu commented May 15, 2024

This should be fixed by #191

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