Vertex AI API Key Incorrrect Padding Error
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
0.6.13
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
Trying to add Google Cloud / Vertex AI in Model Provider results in Padding Error message
✔️ Expected Behavior
No response
❌ Actual Behavior
No response
Hello @breynded! I'm here to help you with any bugs, questions, or contributions you may have for the repository. Let's work together to resolve any issues you're facing.
To resolve the "Incorrect Padding Error" when trying to add Google Cloud / Vertex AI in the Model Provider on a self-hosted Dify version 0.6.13, ensure that the credentials you are providing are correctly formatted and properly padded. This error typically occurs when the base64 encoded credentials are not correctly padded.
Base64 strings should be padded with = characters to make their length a multiple of 4. You can manually add the necessary padding to your base64 encoded credentials. Here is an example of how you can do this in Python:
import base64
def add_padding(base64_string):
return base64_string + '=' * (-len(base64_string) % 4)
# Example usage
credentials = "your_base64_encoded_credentials"
padded_credentials = add_padding(credentials)
Ensure that the padded_credentials are then used in the credentials dictionary when calling the validate_credentials method. This should resolve the "Incorrect Padding Error" [1][2][3].
To continue talking to Dosu, mention @dosu.
when will this bug be fixed and merged @dosu
I updated to dify 0.10.1 and this bug has not been fixed yet !
Hi. I was having the same issue because I was copying the private key inside the JSON file. I managed to configure the Vertex Model by using these settings:
Project-ID: your-project-id Location: us-east1 Service Account Key: Encode the whole JSON text file to base64 (the file generated in IAM->Service Accounts->Create Service Account->Keys->Add Key->Create New Key-> JSON). You can use Python to do that, or this website for instance.