chenhg5/cc-connect · error
%s: invalid resource_chunk_size_bytes %v: %w
Error message
%s: invalid resource_chunk_size_bytes %v: %w
What it means
resource_chunk_size_bytes must be coercible to a number via coerceMilliseconds (shared numeric helper); non-numeric values abort newPlatform with this wrapped error. A valid number below 1 MiB is silently clamped instead of erroring.
Source
Thrown at platform/feishu/feishu.go:438
ms, err := coerceMilliseconds(raw)
if err != nil {
return nil, fmt.Errorf("%s: invalid image_batch_window_ms %v: %w", name, raw, err)
}
if ms < 0 {
return nil, fmt.Errorf("%s: image_batch_window_ms must be >= 0, got %d", name, ms)
}
imageBatchWindow = time.Duration(ms) * time.Millisecond
}
// resource_chunk_size_bytes: byte size for each Range request when chunked-
// downloading Feishu message resources (issue #1741). The larkim SDK does
// not expose Range headers, so for resources above ~2 MiB a plain GET
// returns code=234037. Default 8 MiB; clamped to [1 MiB, 64 MiB].
resourceChunkSize := int64(8 * 1024 * 1024)
if raw, ok := opts["resource_chunk_size_bytes"]; ok {
n, err := coerceMilliseconds(raw)
if err != nil {
return nil, fmt.Errorf("%s: invalid resource_chunk_size_bytes %v: %w", name, raw, err)
}
if n > 0 {
resourceChunkSize = n
}
}
if resourceChunkSize < 1*1024*1024 {
resourceChunkSize = 1 * 1024 * 1024
}
if resourceChunkSize > 64*1024*1024 {
resourceChunkSize = 64 * 1024 * 1024
}
// Webhook mode configuration (for Lark international version)
port, _ := opts["port"].(string)
if port == "" {
port = "8080"
}
callbackPath, _ := opts["callback_path"].(string)View on GitHub (pinned to 4000b2338a)
Solutions
- Provide a plain integer byte count: resource_chunk_size_bytes = 8388608.
- Remove the option to use the 8 MiB default.
- Note values < 1 MiB are clamped up, not rejected — only non-numeric types error.
Example fix
// before (config.toml) resource_chunk_size_bytes = "8MiB" // after resource_chunk_size_bytes = 8388608
Defensive patterns
Strategy: validation
Validate before calling
if raw, ok := opts["resource_chunk_size_bytes"]; ok {
switch raw.(type) {
case int, int64, float32, float64:
default:
log.Fatalf("resource_chunk_size_bytes must be a plain byte count, got %T", raw)
}
} Type guard
func isNumber(v any) bool { switch v.(type) { case int, int64, float32, float64: return true }; return false } Prevention
- Use integer byte counts (8388608), not "8MiB" strings.
- Omit the option to keep the 8 MiB default.
When it happens
Trigger: resource_chunk_size_bytes = "8MiB" (string with unit), true, or a table in feishu platform options.
Common situations: Human-readable byte strings like "8MiB" or "8388608 bytes"; users assuming unit suffixes are parsed.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- expected number, got %T
- %s: invalid image_batch_window_ms %v: %w
- %s: app_id and app_secret are required
- %s: invalid domain %q: %w
- %s: invalid progress_style %q (want legacy, compact, or card
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/8e069d6b5f800321.
Report an issue: GitHub.