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

[bug] invalid utf-8 sequence of 1 bytes from index 1 #3761

Closed
elvinaspredkelis opened this issue Mar 23, 2022 · 10 comments
Closed

[bug] invalid utf-8 sequence of 1 bytes from index 1 #3761

elvinaspredkelis opened this issue Mar 23, 2022 · 10 comments
Assignees

Comments

@elvinaspredkelis
Copy link
Contributor

elvinaspredkelis commented Mar 23, 2022

Describe the bug

Hello,

I get invalid utf-8 sequence of 1 bytes from index 1 error in two cases:

  1. When running tauri build. The build process successfully finishes, however this error is shown in the logs.
  2. When trying to check for/install update, I also get Updater: Signature encoding error: invalid utf-8 sequence of 1 bytes from index 1.

Reproduction

I'm not really sure where to search for the culprit, therefore, unfortunately, I cannot specify the reproduction steps in the new repo. But these are the steps I take in my repository:

Run tauri build

--- OR ---

Run the following script (from the docs)

try {
  const { shouldUpdate } = await checkUpdate()
  if (shouldUpdate) {
    await installUpdate()
    await relaunch()
   }
} catch (error) {
  console.log(error)
}

Expected behavior

No response

Platform and versions

Operating System - Mac OS, version 12.0.1 X64

Node.js environment
  Node.js - 16.6.2
  @tauri-apps/cli - 1.0.0-rc.6
  @tauri-apps/api - 1.0.0-rc.2

Global packages
  npm - 8.3.0
  pnpm - Not installed
  yarn - 1.22.11

Rust environment
  rustup - 1.24.3
  rustc - 1.58.1
  cargo - 1.58.0
  toolchain - stable-x86_64-apple-darwin 

App directory structure
/dist
/node_modules
/public
/src-tauri
/lib
/.git
/src

App
  tauri - 1.0.0-rc.4
  tauri-build - 1.0.0-rc.4
  tao - 0.6.4
  wry - 0.13.3
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - http://localhost:8080/
  framework - Vue.js

Stack trace

No response

Additional context

I'm trying to build the app locally for macOS. I'm also signing and notarizing the build.

@nothingismagick
Copy link
Member

Can you share your repo or at least a minimum reproduction? On a total wild guess, maybe try with a different ICNS icon file...

@elvinaspredkelis
Copy link
Contributor Author

elvinaspredkelis commented Mar 24, 2022

@nothingismagick thanks for the tip!

I've regenerated the ICNS and the error went away when running tauri build.

I'm still getting Updater: Signature encoding error: invalid utf-8 sequence of 1 bytes from index 1 when calling the Tauri API checkUpdate().

I will try to reproduce this in a new repository because the current repo is a little "too big to share".

The minimum reproduction is kind of described in the issue: Just using the same code snippet as in the docs, nothing else.

@nothingismagick
Copy link
Member

ok, we are finalizing some stuff on the updater - so maybe try with latest dev branch instead of the release ?

@elvinaspredkelis
Copy link
Contributor Author

elvinaspredkelis commented Mar 25, 2022

@nothingismagick unfortunately it hasn't fixed the issue.

The error is now Signature encoding error: invalid utf-8 sequence of 1 bytes from index 1, lost the Updater: part but that's probably insignificant.

@nothingismagick
Copy link
Member

ok, pinging @lucasfernog because he has been working on the updater. The better error message is now a bit more helpful. what code editor are you using, what encoding are you using?

@elvinaspredkelis
Copy link
Contributor Author

Thanks!

I'm using VSCode and I'm not entirely sure what encoding I'm using. I haven't been touching the encoding in any way on purpose, so I'm guessing utf-8.

Also, were there any differences between the v1 release contenders and the versions before when it comes to encoding? If so, I could have overlooked something when updating.

As for the updater, I'm strictly following the docs (https://tauri.studio/docs/distribution/updater) and don't have anything extra on top.

@lucasfernog
Copy link
Member

Did you set up the pubkey properly on tauri.conf.json? And also the TAURI_PRIVATE_KEY variable.
I'll see if invalid values can end up with that error.

@lucasfernog
Copy link
Member

Seems like your public key might be wrong. It must have exactly 152 characters.

This is an example output of tauri signer generate:

Generating new private key without password.
Please enter a password to protect the secret key.
Password: 
Password (one more time): 
Deriving a key from the password in order to encrypt the secret key... done

Your secret key was generated successfully - Keep it secret!
dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5UEd4eEc1eHZ5aXlyZUw5dkRuZUROK1ZJZjZpT0xvdVRKMzZ4aWFJY3poQUFBQkFBQUFBQUFBQUFBQUlBQUFBQW0wZHc2RHUxcnVjSGU1RjQyS3hBZDN1SlpYMWVFQ3FPSmFxWHUrNlhrb2FpMnkwTXFEYUVhSHoxV0FOeVpJOERlSUs0Z3BPZXZXWmZGMDJxazMrcjN0M0lwUDRXb09Qd0poRVVVUGI1ZDh5UGpvZ1dCUVY0T1pxZzllQ0tTQys3am5lZDdsWGFMWFk9Cg==


Your public key was generated successfully:
dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDU4QzE1MzE1MDBGNjREMjEKUldRaFRmWUFGVlBCV0szOXZPRjZ5NzhuZEd4UGRXT3ltalhQNy9Xb09UU05xZEVEbS8zdDNkY00K

Add the public key in your tauri.conf.json
---------------------------


Environment variabled used to sign:
`TAURI_PRIVATE_KEY`  Path or String of your private key
`TAURI_KEY_PASSWORD`  Your private key password (optional)

ATTENTION: If you lose your private key OR password, you'll not be able to sign your update package and updates will not works.
---------------------------

In this case, you must set dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDU4QzE1MzE1MDBGNjREMjEKUldRaFRmWUFGVlBCV0szOXZPRjZ5NzhuZEd4UGRXT3ltalhQNy9Xb09UU05xZEVEbS8zdDNkY00K to the pubkey field of the updater object on tauri.conf.json and dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5UEd4eEc1eHZ5aXlyZUw5dkRuZUROK1ZJZjZpT0xvdVRKMzZ4aWFJY3poQUFBQkFBQUFBQUFBQUFBQUlBQUFBQW0wZHc2RHUxcnVjSGU1RjQyS3hBZDN1SlpYMWVFQ3FPSmFxWHUrNlhrb2FpMnkwTXFEYUVhSHoxV0FOeVpJOERlSUs0Z3BPZXZXWmZGMDJxazMrcjN0M0lwUDRXb09Qd0poRVVVUGI1ZDh5UGpvZ1dCUVY0T1pxZzllQ0tTQys3am5lZDdsWGFMWFk9Cg== to the TAURI_PRIVATE_KEY environment variable, along with the TAURI_KEY_PASSWORD.

@elvinaspredkelis
Copy link
Contributor Author

@lucasfernog

Thank you so much! It seems to have solved it 🥳

I'm not sure if this is of any help now, but:

  • I've tried regenerating these keys with the latest release and it would cause the error, but it's not causing it anymore when the repo is pointed to the dev branch.
  • Perhaps it would be amazing to have a more explicit error message in this case. I think that the updater is an essential feature in Tauri, so maybe it would be nice to know that the issue could be that.
  • Somehow regenerating the ICNS file solved the same exact error message when building the app. So an explicit error (or at least an added namespace to the error) would be amazing.

@lucasfernog
Copy link
Member

Thanks for the feedback! I've introduced better validations of response types and added some unit tests too, so finding the issue will be easier next time.

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

No branches or pull requests

3 participants