chenhg5/cc-connect · error

%s: image_batch_window_ms must be >= 0, got %d

Error message

%s: image_batch_window_ms must be >= 0, got %d

What it means

Range check in newPlatform: a successfully coerced image_batch_window_ms that is negative is rejected, since a negative coalescing window is meaningless. Note that 0 is allowed (disables batching delay).

Source

Thrown at platform/feishu/feishu.go:425

		case "compact", "card":
			progressStyle = strings.ToLower(strings.TrimSpace(v))
		default:
			return nil, fmt.Errorf("%s: invalid progress_style %q (want legacy, compact, or card)", name, v)
		}
	}
	useInteractiveCard := true
	if v, ok := opts["enable_feishu_card"].(bool); ok {
		useInteractiveCard = v
	}

	imageBatchWindow := defaultImageBatchWindow
	if raw, ok := opts["image_batch_window_ms"]; ok {
		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
		}
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Set image_batch_window_ms to 0 or a positive integer.
  2. Use 0 if you want minimal/no batching delay; remove the key for the default window.

Example fix

// before (config.toml)
image_batch_window_ms = -100
// after
image_batch_window_ms = 0
Defensive patterns

Strategy: validation

Validate before calling

if ms < 0 {
    log.Fatalf("image_batch_window_ms must be >= 0, got %d", ms)
}

Prevention

When it happens

Trigger: image_batch_window_ms = -100 (or any negative number) in the feishu platform options.

Common situations: Users attempting to 'disable' batching with a negative value; arithmetic in templated configs producing negatives.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/bf155895a6668e56. Report an issue: GitHub.