{"record":{"id":"646cca67da5a1eb4","repo":"elunez/eladmin","slug":"error-646cca","errorCode":null,"errorMessage":"存储桶不存在，请检查配置或权限。","messagePattern":"存储桶不存在，请检查配置或权限。","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"eladmin-tools/src/main/java/me/zhengjie/service/impl/S3StorageServiceImpl.java","lineNumber":83,"sourceCode":"    public PageResult<S3Storage> queryAll(S3StorageQueryCriteria criteria, Pageable pageable){\n        Page<S3Storage> page = s3StorageRepository.findAll((root, criteriaQuery, criteriaBuilder)\n                -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);\n        return PageUtil.toPage(page);\n    }\n\n    @Override\n    public List<S3Storage> queryAll(S3StorageQueryCriteria criteria){\n        return s3StorageRepository.findAll((root, criteriaQuery, criteriaBuilder)\n                -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));\n    }\n\n    @Override\n    @Transactional(rollbackFor = Exception.class)\n    public void deleteAll(List<Long> ids) {\n        // 检查桶是否存在\n        String bucketName = amzS3Config.getDefaultBucket();\n        if (!bucketExists(bucketName)) {\n            throw new BadRequestException(\"存储桶不存在，请检查配置或权限。\");\n        }\n        // 遍历 ID 列表，删除对应的文件和数据库记录\n        for (Long id : ids) {\n            String filePath = s3StorageRepository.selectFilePathById(id);\n            if (filePath == null) {\n                System.err.println(\"未找到 ID 为 \" + id + \" 的文件记录，无法删除。\");\n                continue;\n            }\n            try {\n                // 创建 DeleteObjectRequest，指定存储桶和文件键\n                DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder()\n                        .bucket(bucketName)\n                        .key(filePath)\n                        .build();\n                // 调用 deleteObject 方法\n                s3Client.deleteObject(deleteObjectRequest);\n                // 删除数据库数据\n                s3StorageRepository.deleteById(id);","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/elunez/eladmin/blob/55fbf705956949697dbd68bf9003776609d3d029/eladmin-tools/src/main/java/me/zhengjie/service/impl/S3StorageServiceImpl.java#L65-L101","documentation":"Thrown by S3StorageServiceImpl.deleteAll before deleting any objects: it heads the bucket configured as amzS3Config.getDefaultBucket(), and if bucketExists() reports it missing (or the head call failed with a non-404 S3Exception — see error 96 for that branch), the bulk delete is refused. The 404 branch inside bucketExists logs '存储桶不存在' and returns false, which surfaces here.","triggerScenarios":"DELETE /s3Storage (batch ids) when the configured default bucket name doesn't exist in the S3 account — typo in config, wrong region endpoint, credentials pointing at another account, or the bucket was deleted out-of-band.","commonSituations":"amz-s3 config (bucket name / endpoint / region / keys) entered incorrectly in the admin S3 config page; using a MinIO/other S3-compatible endpoint where the bucket was never created; IAM keys rotated to an account without that bucket; bucket removed while DB records still reference it.","solutions":["Verify the default bucket name in the S3 storage config matches an existing bucket (aws s3 ls or the MinIO console).","Check region/endpoint in amzS3Config — a head-bucket against the wrong region can 404/301.","Confirm the credentials in use belong to the account owning the bucket (a 403 is reported as error 96 instead).","If the bucket was intentionally removed, clean up the s3_storage DB records so deleteAll is not called against stale metadata.","Create the bucket (or upload once, which auto-creates it via createBucket) before using delete."],"exampleFix":"// before\nString bucketName = amzS3Config.getDefaultBucket();\nif (!bucketExists(bucketName)) {\n    throw new BadRequestException(\"存储桶不存在，请检查配置或权限。\");\n}\n\n// after: report which bucket failed to make ops actionable\nString bucketName = amzS3Config.getDefaultBucket();\nif (!bucketExists(bucketName)) {\n    throw new BadRequestException(\"存储桶 \" + bucketName + \" 不存在，请检查配置或权限。\");\n}","handlingStrategy":"validation","validationCode":"// verify bucket resolvable before issuing batch delete\nString bucket = amzS3Config.getDefaultBucket();\nif (!s3Client.listBuckets().buckets().stream().anyMatch(b -> b.name().equals(bucket))) {\n    throw new BadRequestException(\"配置的存储桶不存在，请先修正配置\");\n}","typeGuard":null,"tryCatchPattern":"try { s3StorageService.deleteAll(ids); } catch (BadRequestException e) { if (e.getMessage().contains(\"存储桶不存在\")) { /* config problem: stop and fix bucket name/endpoint, do not retry */ } }","preventionTips":["Validate the bucket name with a head-bucket when saving S3 config in the admin UI.","Keep bucket/endpoint/region/credentials as one reviewed unit — changing one without the others causes this.","After renaming buckets, migrate objects AND update config together."],"tags":["s3","storage","bucket","configuration","aws-sdk-v2"],"backgroundTag":null,"analyzedSha":"55fbf705956949697dbd68bf9003776609d3d029","analyzedAt":"2026-08-14T11:56:12.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}