{"record":{"id":"32148bb713410d77","repo":"iflytek/astron-agent","slug":"exceeds-size-limit","errorCode":null,"errorMessage":" exceeds size limit","messagePattern":" exceeds size limit","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/chat/springai/SkillRuntimeToolService.java","lineNumber":138,"sourceCode":"                .build();\n        try (Response response = client.newCall(request).execute()) {\n            if (!response.isSuccessful()) {\n                throw new IOException(\"Skill resource download failed: HTTP \" + response.code());\n            }\n            ResponseBody body = response.body();\n            if (body == null) {\n                throw new IOException(\"Skill resource download returned empty body\");\n            }\n            return decodeText(readBounded(body, maxResourceBytes, \"Skill resource\"), body);\n        }\n    }\n\n    private byte[] readBounded(ResponseBody body, long limit, String description)\n            throws IOException {\n        validateLimit(limit, description);\n        long contentLength = body.contentLength();\n        if (contentLength > limit) {\n            throw new IOException(description + \" exceeds size limit\");\n        }\n        int readLimit = Math.toIntExact(limit + 1);\n        try (InputStream input = body.byteStream()) {\n            byte[] bytes = input.readNBytes(readLimit);\n            if (bytes.length > limit) {\n                throw new IOException(description + \" exceeds size limit\");\n            }\n            return bytes;\n        }\n    }\n\n    private void validateLimit(long limit, String description) throws IOException {\n        if (limit < 1 || limit > MAX_CONFIGURABLE_RESPONSE_BYTES) {\n            throw new IOException(description + \" size limit is invalid\");\n        }\n    }\n\n    private String decodeText(byte[] bytes, ResponseBody body) {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/chat/springai/SkillRuntimeToolService.java#L120-L156","documentation":"readBounded enforces a hard size cap on HTTP response bodies. Before streaming, it validates the declared Content-Length: if body.contentLength() exceeds the limit it immediately throws \"<description> exceeds size limit\" without reading the body. This protects the console backend from a malicious or misconfigured server delivering an oversized sandbox response or skill resource.","triggerScenarios":"A sandbox response or skill resource whose declared Content-Length header is larger than maxSandboxResponseBytes / maxResourceBytes when executeSandbox or downloadText calls readBounded.","commonSituations":"A skill resource file genuinely larger than the configured cap; a compromised/foreign resource server lying about or sending huge Content-Length; a configured limit left at a very small default while real resources grew; sandbox echoing back a much larger payload than submitted.","solutions":["Reduce the requested resource/response size (truncate, paginate, or fetch a smaller artifact).","If the resource is legitimately needed, raise the maxResourceBytes limit passed to downloadText.","Check why the server declares a larger Content-Length than expected — possibly the wrong file is being served.","Compress resources server-side so their transferred size fits within the cap."],"exampleFix":"// before\nString text = service.downloadText(url, 1024); // resource is 500KB -> rejected before read\n// after\nlong resourceSize = headContentLength(url);\nlong limit = Math.max(resourceSize + 1, MAX_RESOURCE_BYTES);\nString text = service.downloadText(url, limit);","handlingStrategy":"validation","validationCode":"long declared = httpHead(url).headers().get(\"Content-Length\") != null\n        ? Long.parseLong(httpHead(url).headers().get(\"Content-Length\")) : -1;\nif (declared > maxResourceBytes) {\n    throw new IllegalArgumentException(\"Resource too large: \" + declared + \" > \" + maxResourceBytes);\n}","typeGuard":null,"tryCatchPattern":"try {\n    String content = service.downloadText(url, maxResourceBytes);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().endsWith(\"exceeds size limit\")) {\n        // fetch a smaller artifact or raise the configured limit\n    }\n}","preventionTips":["Keep skill resources under the configured size cap and enforce the cap at publish time.","Periodically review limit configuration against actual resource sizes.","Compress large resources server-side before exposing download URLs."],"tags":["http","file-size","security","java","okhttp"],"backgroundTag":"payload-too-large","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}