-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Description
Summary
The mediaMaxMb configuration option defined in WhatsApp account schema is completely ignored during media processing. Despite being configurable at multiple levels, the code always falls back to hardcoded constants.
Details
Schema Defines the Option (But It's Never Used)
File: dist/config/zod-schema.providers-whatsapp.js:29
mediaMaxMb: z.number().int().positive().optional(),This allows users to configure:
channels:
whatsapp:
accounts:
default:
mediaMaxMb: 64 # This is completely ignoredThe Code Path That Ignores It
File: dist/infra/outbound/message-action-runner.js:102-140
The resolveAttachmentMaxBytes function:
function resolveAttachmentMaxBytes(params) {
const fallback = params.cfg.agents?.defaults?.mediaMaxMb;
if (params.channel !== "bluebubbles") {
// WhatsApp path: only reads agents.defaults, ignores channel-specific config
return typeof fallback === "number" ? fallback * 1024 * 1024 : undefined;
}
// Only bluebubbles gets the full config resolution (channel → account → defaults)
// ...
}For WhatsApp:
- ❌ Ignores
channels.whatsapp.accounts.<id>.mediaMaxMb - ❌ Ignores
channels.whatsapp.mediaMaxMb ⚠️ Only readsagents.defaults.mediaMaxMb(which may still be ignored downstream)
Hardcoded Constants Override Everything
File: dist/media/constants.js:1-4
export const MAX_IMAGE_BYTES = 6 * 1024 * 1024; // 6MB
export const MAX_AUDIO_BYTES = 16 * 1024 * 1024; // 16MB
export const MAX_VIDEO_BYTES = 16 * 1024 * 1024; // 16MB
export const MAX_DOCUMENT_BYTES = 100 * 1024 * 1024; // 100MBThese are used by maxBytesForKind() which is called when no maxBytes parameter is passed.
Note on Actual WhatsApp Limits
The hardcoded values are actually correct for WhatsApp Cloud/Web API:
- Video/Audio: 16MB
- Images: 5MB
- Documents: 100MB
(Source: AWS WhatsApp Media Types)
However, the consumer app allows sending videos as documents (up to 100MB), and WhatsApp announced 2GB file sharing support. The config option should work regardless.
Expected Behavior
channels.whatsapp.accounts.<id>.mediaMaxMbshould be read and applied- It should fall back to
channels.whatsapp.mediaMaxMb - Then fall back to
agents.defaults.mediaMaxMb - Finally fall back to the hardcoded defaults
Suggested Fix
Update resolveAttachmentMaxBytes to handle WhatsApp the same way it handles BlueBubbles:
function resolveAttachmentMaxBytes(params) {
const fallback = params.cfg.agents?.defaults?.mediaMaxMb;
// Get channel-specific config
const channelCfg = params.cfg.channels?.[params.channel];
const channelObj = channelCfg && typeof channelCfg === "object" ? channelCfg : undefined;
const channelMediaMax = typeof channelObj?.mediaMaxMb === "number" ? channelObj.mediaMaxMb : undefined;
// Get account-specific config
const accountId = typeof params.accountId === "string" ? params.accountId.trim() : "";
const accountsObj = channelObj?.accounts && typeof channelObj.accounts === "object"
? channelObj.accounts : undefined;
const accountCfg = accountId && accountsObj ? accountsObj[accountId] : undefined;
const accountMediaMax = accountCfg && typeof accountCfg === "object"
? accountCfg.mediaMaxMb : undefined;
// Priority: account → channel → defaults
const limitMb = accountMediaMax ?? channelMediaMax ?? fallback;
return typeof limitMb === "number" ? limitMb * 1024 * 1024 : undefined;
}Environment
- OpenClaw Version: 2026.1.29
- OS: macOS Darwin 24.5.0 (arm64)
- Node: v24.13.0
Related
- Telegram mediaMaxMb config doesn't inherit from agents.defaults #6453 - Telegram mediaMaxMb config doesn't inherit from agents.defaults (similar pattern)