mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-12-05 05:43:36 -05:00
chore(graph): log the resource and the tags in AssignTags (#4156)
UnassignTags logs with a sublogger that carries the request ID, the resource ID and the tags of the request, AssignTags still used the plain service logger. Use the same sublogger in AssignTags, so that the log lines of both handlers can be found by the same fields. Also drop the error from the "no permissionset on file" line: err is always nil there. Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
4f2ab613a2
commit
64a44e77ff
1 file changed
+12
-7
@@ -90,16 +90,21 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
logger := g.logger.SubloggerWithRequestID(ctx).With().
|
||||
Str("resourceID", assignment.ResourceId).
|
||||
Strs("tags", assignment.Tags).
|
||||
Logger()
|
||||
|
||||
rid, err := storagespace.ParseID(assignment.ResourceId)
|
||||
if err != nil {
|
||||
g.logger.Debug().Err(err).Msg("could not parse resourceId")
|
||||
logger.Debug().Err(err).Msg("could not parse resourceId")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid resourceId")
|
||||
return
|
||||
}
|
||||
|
||||
client, err := g.gatewaySelector.Next()
|
||||
if err != nil {
|
||||
g.logger.Error().Err(err).Msg("error selecting next gateway client")
|
||||
logger.Error().Err(err).Msg("error selecting next gateway client")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@@ -107,7 +112,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
Ref: &provider.Reference{ResourceId: &rid},
|
||||
})
|
||||
if err != nil {
|
||||
g.logger.Error().Err(err).Msg("error stating file")
|
||||
logger.Error().Err(err).Msg("error stating file")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
@@ -122,14 +127,14 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
pm := sres.GetInfo().GetPermissionSet()
|
||||
if pm == nil {
|
||||
g.logger.Error().Err(err).Msg("no permissionset on file")
|
||||
logger.Error().Msg("no permissionset on file")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
// it says we need "write access" to set tags. One of those should do
|
||||
if !pm.InitiateFileUpload && !pm.CreateContainer {
|
||||
g.logger.Info().Msg("no permission to create a tag")
|
||||
logger.Info().Msg("no permission to create a tag")
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
@@ -157,7 +162,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
},
|
||||
})
|
||||
if err != nil || resp.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||
g.logger.Error().Err(err).Interface("status", resp.GetStatus()).Msg("error setting tags")
|
||||
logger.Error().Err(err).Interface("status", resp.GetStatus()).Msg("error setting tags")
|
||||
if resp.GetStatus().GetCode() == rpc.Code_CODE_LOCKED {
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusLocked, "file is locked")
|
||||
return
|
||||
@@ -177,7 +182,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
Executant: revaCtx.ContextMustGetUser(r.Context()).Id,
|
||||
}
|
||||
if err := events.Publish(r.Context(), g.eventsPublisher, ev); err != nil {
|
||||
g.logger.Error().Err(err).Msg("Failed to publish TagsAdded event")
|
||||
logger.Error().Err(err).Msg("Failed to publish TagsAdded event")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user