From fbc147158138f3a7e69d8b6c1d915c05684a8387 Mon Sep 17 00:00:00 2001 From: Hein Date: Thu, 18 Dec 2025 11:21:59 +0200 Subject: [PATCH] Fixed panic caused by model type not being pointer in rest header spec. --- pkg/restheadspec/handler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/restheadspec/handler.go b/pkg/restheadspec/handler.go index 6c4ffb8..9abb074 100644 --- a/pkg/restheadspec/handler.go +++ b/pkg/restheadspec/handler.go @@ -1236,7 +1236,12 @@ func (h *Handler) handleUpdate(ctx context.Context, w common.ResponseWriter, id dataMap[pkName] = targetID // Populate model instance from dataMap to preserve custom types (like SqlJSONB) - modelInstance := reflect.New(reflect.TypeOf(model).Elem()).Interface() + // Get the type of the model, handling both pointer and non-pointer types + modelType := reflect.TypeOf(model) + if modelType.Kind() == reflect.Ptr { + modelType = modelType.Elem() + } + modelInstance := reflect.New(modelType).Interface() if err := reflection.MapToStruct(dataMap, modelInstance); err != nil { return fmt.Errorf("failed to populate model from data: %w", err) }