fix call writeJsonError with a nil value error after check another err (#6673)

the dbErr != nil and err is nil

when call writeJsonError with a nil value error, it may panic
This commit is contained in:
alingse
2025-03-29 23:17:36 +08:00
committed by GitHub
parent 669a3917af
commit 46b3a71a1f

View File

@@ -45,7 +45,7 @@ func (fs *FilerServer) PutTaggingHandler(w http.ResponseWriter, r *http.Request)
if dbErr := fs.filer.CreateEntry(ctx, existingEntry, false, false, nil, false, fs.filer.MaxFilenameLength); dbErr != nil {
glog.V(0).Infof("failing to update %s tagging : %v", path, dbErr)
writeJsonError(w, r, http.StatusInternalServerError, err)
writeJsonError(w, r, http.StatusInternalServerError, dbErr)
return
}
@@ -111,7 +111,7 @@ func (fs *FilerServer) DeleteTaggingHandler(w http.ResponseWriter, r *http.Reque
if dbErr := fs.filer.CreateEntry(ctx, existingEntry, false, false, nil, false, fs.filer.MaxFilenameLength); dbErr != nil {
glog.V(0).Infof("failing to delete %s tagging : %v", path, dbErr)
writeJsonError(w, r, http.StatusInternalServerError, err)
writeJsonError(w, r, http.StatusInternalServerError, dbErr)
return
}