From eccbf9535b917535110920d5380b545e84af4429 Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 17 Nov 2025 15:49:32 -0800 Subject: [PATCH] nil check --- weed/s3api/s3api_object_handlers.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index de2e6b305..cb5ec707b 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -129,10 +129,10 @@ func (s3a *S3ApiServer) checkDirectoryObject(bucket, object string) (*filer_pb.E // serveDirectoryContent serves the content of a directory object directly func (s3a *S3ApiServer) serveDirectoryContent(w http.ResponseWriter, r *http.Request, entry *filer_pb.Entry) { - // Validate that entry has attributes - if entry.Attributes == nil { - glog.Errorf("serveDirectoryContent: entry has no attributes") - w.WriteHeader(http.StatusInternalServerError) + // Defensive nil checks - entry and attributes should never be nil, but guard against it + if entry == nil || entry.Attributes == nil { + glog.Errorf("serveDirectoryContent: entry or attributes is nil") + s3err.WriteErrorResponse(w, r, s3err.ErrInternalError) return }