From 64a44e77ff19ed93a9402264f14fe8b258bf5d88 Mon Sep 17 00:00:00 2001 From: Pascal Bleser Date: Tue, 1 Dec 2026 12:59:32 +0100 Subject: [PATCH] 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 --- services/graph/pkg/service/v0/tags.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/services/graph/pkg/service/v0/tags.go b/services/graph/pkg/service/v0/tags.go index e4958f6061..d29a369685 100644 --- a/services/graph/pkg/service/v0/tags.go +++ b/services/graph/pkg/service/v0/tags.go @@ -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") } } }