iflytek/astron-agent · error · BusinessException

S3_UPLOAD_ERROR

S3_UPLOAD_ERROR

Error message

S3_UPLOAD_ERROR

What it means

S3_UPLOAD_ERROR is thrown by S3Util.putObject(key, input, objectSize, contentType) when the MinIO client putObject call fails with any of the wrapped MinIO/IO/crypto exceptions. The original exception is logged at error level, then converted into a BusinessException so callers only see the generic upload-failure response.

Solutions

  1. Check the server log for 'S3 putObject error' to see the underlying MinIO exception and error code (e.g. NoSuchBucket, AccessDenied)
  2. Verify s3.endpoint, s3.accessKey, s3.secretKey and s3.bucket in the service configuration point to a reachable MinIO/S3 with an existing bucket
  3. Confirm the credentials have write (s3:PutObject) permission on the bucket
  4. Test connectivity to the S3 endpoint from the service host (network/firewall/DNS)
  5. Ensure the passed objectSize equals the actual number of bytes available in the input stream, or use the unknown-size putObject variant with a partSize

Example fix

// before
minioClient.putObject(builder.build()); // blind call, generic S3_UPLOAD_ERROR on failure
// after
if (objectSize <= 0) {
    throw new IllegalArgumentException("objectSize must be positive for sized putObject");
}
try {
    minioClient.putObject(builder.build());
} catch (ErrorResponseException e) {
    log.error("putObject failed: code={}, key={}", e.errorResponse().code(), key, e);
    throw new BusinessException(ResponseEnum.S3_UPLOAD_ERROR, e.errorResponse().code());
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate config and args before calling putObject
if (isBlank(s3Bucket)) throw new IllegalStateException("s3.bucket not configured");
if (key == null || key.isBlank()) throw new IllegalArgumentException("object key required");
if (objectSize <= 0) throw new IllegalArgumentException("objectSize must be positive");
// Optionally probe connectivity
try (var s = minioClient.listObjects(ListObjectsArgs.builder().bucket(s3Bucket).maxKeys(1).build()).iterator();) {
    if (s.hasNext()) s.next();
}

Try / catch

try {
    s3Util.putObject(key, input, size, contentType);
} catch (BusinessException e) {
    log.error("upload failed for key={}, check underlying 'S3 putObject error' log", key, e);
    throw e; // or return a typed failure to the caller
}

Prevention

When it happens

Trigger: minioClient.putObject(PutObjectArgs with bucket, object key, stream(input, objectSize, -1)) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, ServerException, or XmlParserException.

Common situations: Bucket does not exist or wrong s3.bucket config; access/secret key revoked or clock skew causing signature errors; S3/MinIO endpoint unreachable or network partition; object key contains illegal characters; declared objectSize mismatching actual stream data; bucket write policy denies the user.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/util/S3Util.java:131

            PutObjectArgs.Builder builder = PutObjectArgs.builder();
            builder.bucket(bucketName);
            builder.object(key);
            builder.stream(input, objectSize, -1);
            if (contentType != null && !contentType.isEmpty()) {
                builder.contentType(contentType);
            }
            minioClient.putObject(builder.build());
        } catch (ErrorResponseException
                | InsufficientDataException
                | InternalException
                | InvalidKeyException
                | InvalidResponseException
                | IOException
                | NoSuchAlgorithmException
                | ServerException
                | XmlParserException e) {
            log.error("S3 putObject error: {}", e.getMessage(), e);
            throw new BusinessException(ResponseEnum.S3_UPLOAD_ERROR);
        }
    }

    /**
     * Upload an object of unknown size using multipart; {@code partSize} is required.
     *
     * @param key object key (path within the bucket)
     * @param input input stream containing the object data (size unknown)
     * @param contentType optional MIME type (e.g., {@code application/octet-stream}); may be null or
     *        empty
     * @param partSize multipart chunk size in bytes (recommended ≥ 5MB)
     * @throws BusinessException when MinIO returns an error or any I/O/crypto error occurs
     */
    public void putObject(String key, InputStream input, String contentType, long partSize) {
        try {
            PutObjectArgs.Builder builder = PutObjectArgs.builder();
            builder.bucket(bucketName);
            builder.object(key);

View on GitHub (pinned to 5e758547a8)