{"record":{"id":"6d3fdddd735e1929","repo":"iflytek/astron-agent","slug":"internal-server-error-businessexception-responseenum","errorCode":"INTERNAL_SERVER_ERROR","errorMessage":"BusinessException(ResponseEnum.INTERNAL_SERVER_ERROR)","messagePattern":"BusinessException\\(ResponseEnum\\.INTERNAL_SERVER_ERROR\\)","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/skill/SkillFileService.java","lineNumber":803,"sourceCode":"    }\n\n    private String safeSegment(String value) {\n        return StringUtils.defaultString(value)\n                .replaceAll(\"[^a-zA-Z0-9._-]\", \"-\")\n                .replaceAll(\"-{2,}\", \"-\");\n    }\n\n    private String readContent(SkillFile file) {\n        if (StringUtils.isBlank(file.getObjectKey())) {\n            return \"\";\n        }\n        try (InputStream input = s3Util.getObject(file.getObjectKey())) {\n            if (input == null) {\n                return \"\";\n            }\n            return new String(input.readAllBytes(), StandardCharsets.UTF_8);\n        } catch (IOException ex) {\n            throw new BusinessException(ResponseEnum.INTERNAL_SERVER_ERROR);\n        }\n    }\n\n    private String readMultipartContent(MultipartFile file) {\n        try {\n            return new String(file.getBytes(), StandardCharsets.UTF_8);\n        } catch (IOException e) {\n            throw new BusinessException(ResponseEnum.INTERNAL_SERVER_ERROR);\n        }\n    }\n\n    private boolean isSkillFile(String name) {\n        return StringUtils.equalsIgnoreCase(name, SKILL_FILE_NAME);\n    }\n\n    private SkillMetadata extractSkillMetadata(String content, String fallbackName) {\n        String name = null;\n        String description = null;","sourceCodeStart":785,"sourceCodeEnd":821,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/skill/SkillFileService.java#L785-L821","documentation":"SkillFileService.readFileFromS3 wraps S3 download/IO failures in a generic INTERNAL_SERVER_ERROR BusinessException. It means the skill file object could not be read from object storage (S3/MinIO) or the stream could not be read as bytes. The service deliberately hides the underlying IOException behind the platform's generic 500 code.","triggerScenarios":"Calling the skill file read API whose file record points at S3: s3Util.getObject(file.getObjectKey()) throws IOException (object missing, wrong bucket/key, storage down, credentials invalid) or input.readAllBytes() fails mid-stream.","commonSituations":"MinIO/S3 not running or unreachable in the deployment; object key in the skill_file row is stale after a bucket migration or manual deletion; wrong S3 credentials/bucket config in application.yml; network timeout between toolkit service and storage.","solutions":["Verify MinIO/S3 is up and reachable from the toolkit service (docker compose ps, check the storage endpoint config).","Check that the object exists at the stored objectKey in the configured bucket (aws s3 ls / mc ls).","Validate s3 access-key/secret/bucket settings in the toolkit service configuration.","Check the log for the suppressed IOException near this BusinessException to see the real cause.","Re-upload the skill file to recreate a valid object record."],"exampleFix":"// before\ncatch (IOException ex) {\n    throw new BusinessException(ResponseEnum.INTERNAL_SERVER_ERROR);\n}\n// after\ncatch (IOException ex) {\n    log.error(\"Failed to read skill file from S3, key={}\", file.getObjectKey(), ex);\n    throw new BusinessException(ResponseEnum.INTERNAL_SERVER_ERROR);\n}","handlingStrategy":"try-catch","validationCode":"boolean objectReachable = s3Util.doesObjectExist(bucket, file.getObjectKey());\nif (!objectReachable) throw new IllegalStateException(\"Skill file object missing: \" + file.getObjectKey());","typeGuard":null,"tryCatchPattern":"try {\n    String content = readSkillFile(record);\n} catch (BusinessException e) {\n    if (\"INTERNAL_SERVER_ERROR\".equals(e.getCode())) {\n        log.warn(\"Skill file read failed; check S3 availability/config\", e);\n    }\n}","preventionTips":["Health-check MinIO/S3 before relying on skill file reads.","Never delete S3 objects referenced by skill_file rows without cleaning the rows first.","Pin storage endpoint/credentials in one shared config checked into deployment templates.","Log the underlying IOException at throw time for diagnosability."],"tags":["java","s3","io","file-read"],"backgroundTag":"file-read-failed","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"}