Invalid base64-encoded string: number of data characters (1565) cannot be 1 more than a multiple of 4 #6833

Closed
opened 2026-02-21 18:17:31 -05:00 by yindo · 4 comments
Owner

Originally created by @dadastory on GitHub (Nov 19, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.11.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When I add a model key, I always get the error Invalid base64-encoded string: number of data characters (1565) cannot be 1 more than a multiple of 4, and cannot load any model.

image

✔️ Expected Behavior

Add normally without error

Actual Behavior

get the error Invalid base64-encoded string: number of data characters (1565) cannot be 1 more than a multiple of 4
Not sure what the problem is

Originally created by @dadastory on GitHub (Nov 19, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.11.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When I add a model key, I always get the error Invalid base64-encoded string: number of data characters (1565) cannot be 1 more than a multiple of 4, and cannot load any model. ![image](https://github.com/user-attachments/assets/f501323b-33b8-4dcf-b7a3-2fac03de6bc1) ### ✔️ Expected Behavior Add normally without error ### ❌ Actual Behavior get the error Invalid base64-encoded string: number of data characters (1565) cannot be 1 more than a multiple of 4 Not sure what the problem is
yindo added the 🐞 bug🤔 cant-reproduce labels 2026-02-21 18:17:31 -05:00
yindo closed this issue 2026-02-21 18:17:31 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 19, 2024):

The error you're encountering, "Invalid base64-encoded string: number of data characters (1565) cannot be 1 more than a multiple of 4," typically occurs when the base64 string is not properly padded or formatted. Here are a few steps you can take to resolve this issue:

  1. Check the Input String: Ensure that the base64 string you are using is correctly formatted. A valid base64 string should have a length that is a multiple of 4. If it's not, you might need to add padding characters (=) at the end.

  2. Verify the Source of the String: If the base64 string is generated by a script or another application, verify that the generation process is correct and that no characters are being truncated or altered.

  3. Inspect the Encoding Process: If you are encoding the string yourself, ensure that the encoding process is correctly implemented. You might want to use a reliable library or tool to handle base64 encoding.

  4. Review Related Code: If this error is occurring within a specific part of the Dify codebase, you might want to check the relevant functions for base64 encoding and decoding. For example, in Dify, the compressAndEncodeBase64 function in web/public/embed.js handles base64 encoding [1].

If these steps do not resolve the issue, you might want to look into any recent changes in your setup or configuration that could have affected the encoding process.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Nov 19, 2024): <!-- Answer --> The error you're encountering, "Invalid base64-encoded string: number of data characters (1565) cannot be 1 more than a multiple of 4," typically occurs when the base64 string is not properly padded or formatted. Here are a few steps you can take to resolve this issue: 1. **Check the Input String**: Ensure that the base64 string you are using is correctly formatted. A valid base64 string should have a length that is a multiple of 4. If it's not, you might need to add padding characters (`=`) at the end. 2. **Verify the Source of the String**: If the base64 string is generated by a script or another application, verify that the generation process is correct and that no characters are being truncated or altered. 3. **Inspect the Encoding Process**: If you are encoding the string yourself, ensure that the encoding process is correctly implemented. You might want to use a reliable library or tool to handle base64 encoding. 4. **Review Related Code**: If this error is occurring within a specific part of the Dify codebase, you might want to check the relevant functions for base64 encoding and decoding. For example, in Dify, the `compressAndEncodeBase64` function in `web/public/embed.js` handles base64 encoding <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/public/embed.js)</sup>. If these steps do not resolve the issue, you might want to look into any recent changes in your setup or configuration that could have affected the encoding process. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Nov 19, 2024):

Please provide the container logs and payload as well.

@crazywoola commented on GitHub (Nov 19, 2024): Please provide the container logs and payload as well.
Author
Owner

@dadastory commented on GitHub (Nov 19, 2024):

Please provide the container logs and payload as well.
It's just a Get request, there's no payload, and the logs don't show any errors
image
image

@dadastory commented on GitHub (Nov 19, 2024): > Please provide the container logs and payload as well. It's just a Get request, there's no payload, and the logs don't show any errors ![image](https://github.com/user-attachments/assets/9abe13cc-748f-476b-aa63-4da946a68ced) ![image](https://github.com/user-attachments/assets/7871be66-71f6-4114-9246-bad5390f2cdf)
Author
Owner

@dadastory commented on GitHub (Nov 21, 2024):

i finally run this command and fix it

flask reset-encrypt-key-pair

i have no idea what happen, and i have to set api-key again

@dadastory commented on GitHub (Nov 21, 2024): i finally run this command and fix it ```python flask reset-encrypt-key-pair ``` i have no idea what happen, and i have to set api-key again
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6833