use waddling_errors_macros::{component, component_location, diag};
component_location!(Storage, role = developer);
component! {
Storage {
docs: "S3-compatible object storage. Handles file uploads, downloads, versioning, and presigned URL generation.",
examples: [
"E.Storage.Permission.DENIED: S3 bucket access denied",
"C.Storage.Data.CORRUPTED: Object integrity check failed (corrupt upload)",
"K.Storage.Data.UPLOADED: Multipart upload completed successfully"
],
tags: ["files", "s3", "objects"],
},
}
diag! {
<json, html>,
E.Storage.Permission.DENIED: {
message: "S3 bucket access denied",
'CR 'Pub description: "Access to the S3 bucket was denied. Insufficient permissions for the requested operation.",
'CR 'Pub hints: [
"Check IAM permissions",
"Verify bucket policy"
],
'CR 'Int hints: [
"Review IAM role assignments",
"Check bucket ACLs",
"Verify cross-account access settings"
],
'R role: "Internal",
'R tags: ["storage", "permissions", "s3"],
},
C.Storage.Data.CORRUPTED: {
message: "CRITICAL: Object corruption detected",
'CR 'Pub description: "Object corruption was detected during integrity check. The stored data does not match the expected checksum.",
'CR 'Pub hints: [
"Verify upload integrity",
"Retry upload",
"Check storage health"
],
'CR 'Int hints: [
"Compare MD5/SHA256 checksums",
"Check S3 versioning status",
"Review upload logs for errors"
],
'R role: "Internal",
'R tags: ["storage", "integrity", "critical"],
'R related_codes: ["C.Db.Data.CORRUPTED"],
},
E.Storage.Data.ALREADY_EXISTS: {
message: "Object already exists - upload conflict",
'CR 'Pub description: "The object already exists in storage. Cannot overwrite without explicit permission.",
'CR 'Pub hints: [
"Use versioning",
"Check for existing object"
],
'CR 'Dev hints: [
"Enable S3 versioning on bucket",
"Use conditional PUT with If-None-Match"
],
'R role: "Developer",
'R tags: ["storage", "conflict"],
},
E.Storage.Data.NOT_FOUND: {
message: "Object not found in storage",
'CR 'Pub description: "The requested object does not exist in the storage bucket.",
'CR 'Pub hints: [
"Verify object key",
"Check if object was deleted"
],
'CR 'Dev hints: [
"List bucket contents to verify",
"Check object versioning history"
],
'R role: "Developer",
'R tags: ["storage", "notfound"],
},
K.Storage.Data.UPLOADED: {
message: "Multipart upload completed successfully",
'CR 'Pub description: "The multipart upload operation completed successfully. All parts have been uploaded and assembled.",
'CR 'Pub hints: [
"Object is now available"
],
'CR 'Dev hints: [
"Verify object ETag",
"Clean up any temporary upload state"
],
'R role: "Developer",
'R tags: ["storage", "upload", "success"],
},
T.Storage.Data.TRACE: {
message: "Storage operation trace - debugging enabled",
'CR 'Pub description: "Trace-level logging for storage operations. Used for debugging and performance analysis.",
'CR 'Int hints: [
"Review operation timing",
"Check API call patterns"
],
'R role: "Internal",
'R tags: ["storage", "debug", "trace"],
},
}