iflytek/astron-agent · error · IOException
size limit is invalid
Error message
size limit is invalid
What it means
validateLimit guards the configurable size limits used by executeSandbox, downloadText, and readBounded. The configured limit (maxSandboxResponseBytes or maxResourceBytes, both Spring @Value properties) must be between 1 and MAX_CONFIGURABLE_RESPONSE_BYTES (20 MiB). When the property is misconfigured to 0, a negative number, or something above 20 MiB, the service refuses to start the operation and throws this IOException instead of downloading/reading anything.
Solutions
- Set skill.runtime.max-resource-bytes and skill.runtime.max-sandbox-response-bytes to values in the range 1..20971520 in application.yml or environment.
- Check for conflicting overrides (env vars, profile-specific yml, config server) that push the value outside the allowed range or make it 0/negative.
- If a larger limit is genuinely required, raise the constant MAX_CONFIGURABLE_RESPONSE_BYTES in SkillRuntimeToolService.java deliberately, understanding it caps memory per download.
- Log the effective property values at startup to catch misconfiguration before a request hits the validation.
Example fix
// before (application.yml)
skill:
runtime:
max-resource-bytes: 0
// after
skill:
runtime:
max-resource-bytes: 1048576 # 1 MiB, within 1..20971520 Defensive patterns
Strategy: validation
Validate before calling
long MAX = 20L * 1024 * 1024;
boolean limitOk = maxResourceBytes >= 1 && maxResourceBytes <= MAX;
if (!limitOk) throw new IllegalStateException(
"skill.runtime.max-resource-bytes must be in [1, " + MAX + "], got: " + maxResourceBytes); Try / catch
try {
String text = skillRuntimeToolService.downloadText(url);
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().endsWith("size limit is invalid")) {
// misconfigured limit: fail fast with config context
throw new ConfigurationException("Check skill.runtime.*-bytes settings", e);
}
throw e;
} Prevention
- Add a @PostConstruct startup check that asserts both size-limit properties are within 1..20971520.
- Never configure 0 to mean unlimited — pick a large valid value instead.
- Use Spring's configuration property binding with validation annotations (@Positive, @Max) so bad values fail at boot.
When it happens
Trigger: Calling executeSandbox when skill.runtime.max-sandbox-response-bytes is <=0 or >20971520; calling downloadText when skill.runtime.max-resource-bytes is <=0 or >20971520; readBounded re-validates on every read so any invalid property value surfaces here before the HTTP body is consumed.
Common situations: Operator sets skill.runtime.max-resource-bytes=0 thinking 0 means unlimited; a typo like 30m or a raw byte value above 20971520 (20 MiB) is put in application.yml; an environment variable override injects an empty or negative value; defaults removed from config leaving an unparseable/negative value.
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 iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/354c7ffde6a2f777.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/chat/springai/SkillRuntimeToolService.java:152
throws IOException {
validateLimit(limit, description);
long contentLength = body.contentLength();
if (contentLength > limit) {
throw new IOException(description + " exceeds size limit");
}
int readLimit = Math.toIntExact(limit + 1);
try (InputStream input = body.byteStream()) {
byte[] bytes = input.readNBytes(readLimit);
if (bytes.length > limit) {
throw new IOException(description + " exceeds size limit");
}
return bytes;
}
}
private void validateLimit(long limit, String description) throws IOException {
if (limit < 1 || limit > MAX_CONFIGURABLE_RESPONSE_BYTES) {
throw new IOException(description + " size limit is invalid");
}
}
private String decodeText(byte[] bytes, ResponseBody body) {
MediaType contentType = body.contentType();
if (contentType == null) {
return new String(bytes, StandardCharsets.UTF_8);
}
Charset configuredCharset = contentType.charset();
Charset charset = configuredCharset == null ? StandardCharsets.UTF_8 : configuredCharset;
return new String(bytes, charset);
}
private void validateResourceUrl(String url) throws IOException {
final URI candidate;
final URI configuredOrigin;
try {
candidate = new URI(StringUtils.trimToEmpty(url));View on GitHub (pinned to 5e758547a8)