-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix base64 validation in the image process pipeline #960
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
base: main
Are you sure you want to change the base?
Conversation
|
@TonyGeez Did your problem get fixed? After trying to repackage and run it in the way you suggested, there are still errors. |
Enhanced logging for image caching and retrieval, including error details and type information.
Yes. Btw, I just updated TonyGeez:fix/base64-image branch with a tiny 2 lines update. How do you send your image to ai? |
Screenshot and paste to command line |
|
Were you able to make it work ? |
|
Try also use |
|
Can you show your config.json? |
{
"LOG": true,
"LOG_LEVEL": "debug",
"CLAUDE_PATH": "",
"HOST": "127.0.0.1",
"PORT": 3456,
"APIKEY": "",
"API_TIMEOUT_MS": "600000",
"PROXY_URL": "http://127.0.0.1:7897",
"transformers": [],
"Providers": [
{
"name": "openrouter",
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
"api_key": "sk-or-v1-",
"models": [
"anthropic/claude-3.7-sonnet:thinking",
"anthropic/claude-haiku-4.5",
"anthropic/claude-sonnet-4.5",
"openai/gpt-5",
"google/gemini-2.5-pro",
"anthropic/claude-opus-4.1",
"anthropic/claude-sonnet-4",
"anthropic/claude-3.7-sonnet",
"google/gemini-2.5-flash"
],
"transformer": {
"use": ["openrouter"]
}
}
],
"StatusLine": {
"enabled": true,
"currentStyle": "default",
"default": {
"modules": []
},
"powerline": {
"modules": []
}
},
"Router": {
"default": "openrouter,anthropic/claude-sonnet-4.5",
"background": "openrouter,anthropic/claude-sonnet-4.5",
"think": "openrouter,anthropic/claude-opus-4.1",
"longContext": "openrouter,anthropic/claude-sonnet-4.5",
"longContextThreshold": 600000,
"webSearch": "openrouter,anthropic/claude-sonnet-4.5",
"image": "openrouter,anthropic/claude-sonnet-4.5"
},
"CUSTOM_ROUTER_PATH": ""
}
|
UPDATEFinally pinpointed the issue and error occurs due to how request transformers work and it totally make sense. When Anthropic models (like Claude) are configured under a provider other than Anthropic API endpoint, eg using the OpenRouter transformer, requests are automatically converted to OpenAI-style format. However, when these OpenAI-formatted requests reach Anthropic's endpoints, they're rejected because Anthropic expects its own native request format. This made me realize it make sense and i think isn't technically a bug, it's the expected behavior when you think about it. If we specify OpenRouter as the transformer, it formats requests for OpenAI compatibility. Anthropic's API, being a separate service with its own specifications, cannot (won't/will never) process these OpenAI-formatted requests. SOLUTIONCreate a separate provider entry specifically for Anthropic models from OpenRouter and set Anthropic as transformer. This ensures requests use Anthropic's native transformer, maintaining proper format compatibility: {
"Providers": [
{
"name": "openrouter",
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
"api_key": "sk-or-v1-",
"models": [
"openai/gpt-5",
"google/gemini-2.5-pro",
"google/gemini-2.5-flash"
],
"transformer": {
"use": ["openrouter"]
}
},
{
"name": "openrouter_claude",
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
"api_key": "sk-or-v1-",
"models": [
"anthropic/claude-sonnet-4",
"anthropic/claude-3.7-sonnet"
],
"transformer": {
"use": ["anthropic"]
}
}
]
} |
|
Thank you very much, this indeed solved the problem. I wonder if it's possible to mention this situation in the configuration document, or is there something I missed while reading the document? |






Description
API requests failing with
400 invalid base64 dataerrors when processing images through the imageAgent. (See #958 & #953)The error occurred when corrupted or incomplete base64 strings were sent to the API.
Fix
Changes
ImageCache.storeImage()to validate base64 before cachingImageCache.getImage()to validate on retrieval and clean up bad entriesreqHandler()when processing image