iflytek/astron-agent · warning

Unsupported image size

Error message

Unsupported image size: {}, using default size: {}

What it means

validateImageSize checks the requested image dimension against ALLOWED_IMAGE_SIZES before calling the BotAI image API. A null size silently becomes DEFAULT_IMAGE_SIZE; a non-null but unsupported value logs this warning naming both the rejected size and the default, then returns DEFAULT_IMAGE_SIZE. The API call proceeds with the default rather than failing.

Solutions

  1. Add the requested size to ALLOWED_IMAGE_SIZES if it is genuinely supported by the BotAI image API
  2. Snap unsupported sizes to the nearest allowed value instead of always defaulting to smallest/largest
  3. Validate size in the frontend/controller against the same whitelist and reject early with a clear message
  4. Keep the clamp behavior if acceptable; log at info rather than warn to reduce noise

Example fix

// before
if (!ALLOWED_IMAGE_SIZES.contains(size)) {
    log.warn("Unsupported image size: {}, using default size: {}", size, DEFAULT_IMAGE_SIZE);
    return DEFAULT_IMAGE_SIZE;
}
// after
if (!ALLOWED_IMAGE_SIZES.contains(size)) {
    int nearest = ALLOWED_IMAGE_SIZES.stream()
        .min(Comparator.comparingInt(s -> Math.abs(s - size)))
        .orElse(DEFAULT_IMAGE_SIZE);
    log.warn("Unsupported image size: {}, snapping to {}", size, nearest);
    return nearest;
}
Defensive patterns

Strategy: validation

Validate before calling

// validate on the caller side before requesting an image
Set<Integer> ALLOWED = Set.of(256, 512, 1024);
if (requestedSize != null && !ALLOWED.contains(requestedSize)) {
    throw new IllegalArgumentException("size must be one of " + ALLOWED);
}

Type guard

boolean isAllowedImageSize(Integer size) {
    return size != null && ALLOWED_IMAGE_SIZES.contains(size);
}

Try / catch

int size = client.validateImageSize(requestedSize);
if (size != requestedSize && requestedSize != null) {
    log.info("Requested size {} was clamped to {}", requestedSize, size);
}

Prevention

When it happens

Trigger: imageSize() is invoked with size values outside ALLOWED_IMAGE_SIZES — frontend sends a pixel value the backend whitelist doesn't include (e.g. 768 vs allowed {256,512,1024}), a client sends size as a different unit, or an older client sends a removed option.

Common situations: Frontend/backend whitelist drift after adding new size options; clients hardcoding sizes not in the allowed set; users selecting 'custom' sizes in UI; API consumers passing string-parsed values that map to odd integers.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/db38c753f5cb79a0. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/util/BotAIServiceClient.java:434

            RoleContent roleContent = new RoleContent("user", question);
            text.add(JSON.toJSON(roleContent));
            message.put("text", text);
            payload.put("message", message);
            requestJson.put("payload", payload);

            return requestJson;
        }
    }

    /**
     * Validate image size
     */
    private int validateImageSize(Integer size) {
        if (size == null) {
            return DEFAULT_IMAGE_SIZE;
        }
        if (!ALLOWED_IMAGE_SIZES.contains(size)) {
            log.warn("Unsupported image size: {}, using default size: {}", size, DEFAULT_IMAGE_SIZE);
            return DEFAULT_IMAGE_SIZE;
        }
        return size;
    }

    /**
     * Build image generation request data
     */
    private JSONObject buildImageGenerationRequest(String imageAppId, String uid, String prompt, int size) {
        JSONObject request = new JSONObject();

        // Build header
        JSONObject header = new JSONObject();
        header.put("app_id", imageAppId);
        header.put("uid", uid);
        request.put("header", header);

        // Build parameter

View on GitHub (pinned to 5e758547a8)