Skip to content

Commit c1ab6e1

Browse files
admin: Only log fields being changed in dry-run UpdateIncident (#8842)
The dry-run UpdateIncident log recorded zero values (1970 timestamps, enabled=false) for fields the request leaves unset. A real UpdateIncident only applies non-empty fields, so the dry-run record misrepresented what a real run would do. Log only the fields present in the request, so "absent" always means "not changed". This PR was generated as part of an audit of #8606 using Claude Fable 5.
1 parent fea684f commit c1ab6e1

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

cmd/admin/dryrun.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,21 @@ func (d dryRunSAAdmin) CreateIncident(ctx context.Context, req *sapb.CreateIncid
109109
}
110110

111111
func (d dryRunSAAdmin) UpdateIncident(ctx context.Context, req *sapb.UpdateIncidentRequest, _ ...grpc.CallOption) (*sapb.Incident, error) {
112-
d.log.Info(ctx, "dry-run: saa.UpdateIncident",
113-
slog.String("incident", req.SerialTable),
114-
slog.String("url", req.Url),
115-
slog.Time("renewBy", req.RenewBy.AsTime()),
116-
slog.Bool("enabled", req.GetEnabled()),
117-
)
112+
// Only log the fields the request would actually change: a real
113+
// UpdateIncident only applies non-empty fields, and logging zero values
114+
// (1970 timestamps, enabled=false) for unset fields would misrepresent
115+
// what a real run would do.
116+
attrs := []slog.Attr{slog.String("incident", req.SerialTable)}
117+
if req.Url != "" {
118+
attrs = append(attrs, slog.String("url", req.Url))
119+
}
120+
if req.RenewBy != nil {
121+
attrs = append(attrs, slog.Time("renewBy", req.RenewBy.AsTime()))
122+
}
123+
if req.Enabled != nil {
124+
attrs = append(attrs, slog.Bool("enabled", *req.Enabled))
125+
}
126+
d.log.Info(ctx, "dry-run: saa.UpdateIncident", attrs...)
118127

119128
out := &sapb.Incident{SerialTable: req.SerialTable, Url: req.Url, RenewBy: req.RenewBy}
120129
if req.Enabled != nil {

0 commit comments

Comments
 (0)