Fix upload_image_to_assets 404 en Forge (header Host) + guard data-URI
- saveFileBuilder (fileBuilder.js) hacía POST directo a viewer_functions.php sin header Host -> en Forge (api_web_url interno http://web:80) Apache servía el vhost por defecto -> 404. Ahora delega en AcaiHttpClient.postViewerAction, que resuelve api_web_url + Host: forge_host (igual que el resto de tools). Pasa credentials completo. - upload_record_image: rechaza data-URI/base64 con error claro (antes derivaba el nombre del base64 -> "File name too long" en mcp_respond.php). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,25 @@ export function registerUploadRecordImageTool(server) {
|
||||
);
|
||||
if (validationError) return validationError;
|
||||
|
||||
// Rechazar data-URI / base64 crudo: derivar el nombre de fichero
|
||||
// del base64 produce nombres de miles de chars que revientan
|
||||
// file_put_contents ("File name too long"). Exigir URL http real.
|
||||
const trimmedImage = imageUrl.trim();
|
||||
const isHttpUrl = /^https?:\/\//i.test(trimmedImage);
|
||||
const isFsPath = trimmedImage.startsWith("/") && !trimmedImage.startsWith("//");
|
||||
if (!isHttpUrl && !isFsPath) {
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
text: JSON.stringify({
|
||||
error: "imageUrl must be an http(s) URL, not a data URI or raw base64. " +
|
||||
"First upload the image with the 'upload_image_to_assets' tool and pass the returned imageUrl here."
|
||||
}, null, 2)
|
||||
}],
|
||||
isError: true,
|
||||
};
|
||||
}
|
||||
|
||||
const projectSlug = path.basename(resolveCurrentProjectDir());
|
||||
|
||||
// Intentar via Python server (tiene sync + optimizacion)
|
||||
|
||||
@@ -154,7 +154,7 @@ export function registerUploadImageToAssetsTool(server) {
|
||||
|
||||
// Upload using saveFileBuilder
|
||||
const uploadResult = await saveFileBuilder({
|
||||
web_url: credentials.api_web_url || credentials.web_url,
|
||||
credentials,
|
||||
token: credentials.token,
|
||||
tokenHash: credentials.tokenHash,
|
||||
path: assetsPath,
|
||||
|
||||
Reference in New Issue
Block a user