{"record":{"id":"56fa918e2d613f0e","repo":"iflytek/astron-agent","slug":"50006-system-s3-presign-error","errorCode":"50006","errorMessage":"system.s3.presign.error","messagePattern":"system\\.s3\\.presign\\.error","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/S3ClientUtil.java","lineNumber":979,"sourceCode":"    }\n\n    /**\n     * Generate a presigned GET URL for reading/downloading an object.\n     *\n     * @param bucketName target bucket\n     * @param objectKey object key\n     * @param expirySeconds expiry in seconds (MinIO requires 1..604800)\n     * @return URL usable for HTTP GET\n     */\n    public String generatePresignedGetUrl(String bucketName, String objectKey, int expirySeconds) {\n        // Validate parameters\n        if (bucketName == null || bucketName.trim().isEmpty()) {\n            log.error(\"Bucket name cannot be null or empty\");\n            throw new BusinessException(ResponseEnum.S3_PRESIGN_ERROR);\n        }\n        if (objectKey == null || objectKey.trim().isEmpty()) {\n            log.error(\"Object key cannot be null or empty\");\n            throw new BusinessException(ResponseEnum.S3_PRESIGN_ERROR);\n        }\n        if (expirySeconds < 1 || expirySeconds > 604800) {\n            log.error(\"Expiry seconds must be between 1 and 604800, got: {}\", expirySeconds);\n            throw new BusinessException(ResponseEnum.S3_PRESIGN_ERROR);\n        }\n\n        try {\n            return presignClient.getPresignedObjectUrl(\n                    GetPresignedObjectUrlArgs.builder()\n                            .method(Method.GET)\n                            .bucket(bucketName)\n                            .object(objectKey)\n                            .expiry(expirySeconds)\n                            .build());\n        } catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidKeyException\n                | InvalidResponseException | IOException | NoSuchAlgorithmException | XmlParserException\n                | ServerException e) {\n            log.error(","sourceCodeStart":961,"sourceCodeEnd":997,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/S3ClientUtil.java#L961-L997","documentation":"generatePresignedGetUrl throws the same BusinessException built from ResponseEnum.S3_PRESIGN_ERROR (code 50006, message 'system.s3.presign.error') when the objectKey is null or blank. It is argument validation before any SDK interaction; the numeric code 50006 is what callers see in the error response body.","triggerScenarios":"Calling generatePresignedGetUrl(bucket, null, expiry) or with an empty/whitespace object key — e.g. a stored file record with a missing object key field.","commonSituations":"Database record has NULL object_key, a download endpoint received a missing/blank key parameter, or key derivation from an id produced an empty string.","solutions":["Validate the object key in the caller/endpoint layer and return a 400-style error instead of hitting presign","Repair the data: backfill the missing object key on the stored record","Fix key derivation so it cannot produce an empty value"],"exampleFix":"// before\nString url = s3ClientUtil.generatePresignedGetUrl(bucket, record.getObjectKey(), 3600);\n// after\nString key = record.getObjectKey();\nif (key == null || key.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"Record has no object key: \" + record.getId());\n}\nString url = s3ClientUtil.generatePresignedGetUrl(bucket, key, 3600);","handlingStrategy":"validation","validationCode":"if (objectKey == null || objectKey.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"objectKey required for presigned GET\");\n}","typeGuard":"static boolean hasText(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try {\n    return s3ClientUtil.generatePresignedGetUrl(bucket, key, expiry);\n} catch (BusinessException e) {\n    if (\"50006\".equals(String.valueOf(e.getCode()))) {\n        log.error(\"presign GET rejected for key '{}'\", key, e);\n    }\n    throw e;\n}","preventionTips":["Treat object key as a required column; enforce NOT NULL in the schema","Validate the key parameter in download endpoints before presigning","Backfill or quarantine records with missing object keys"],"tags":["s3","presign","validation","null"],"backgroundTag":"empty-required-field","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"}