From 3d614a886e752e319e01e3a72d1865ea855ec98d Mon Sep 17 00:00:00 2001 From: Hjalte Hesbjerg Date: Mon, 8 Dec 2025 12:05:48 +0100 Subject: [PATCH] Fix Device.UnmarshalJSON rejecting empty description string NetBox 4.4.7 webhooks send device data with description as an empty string "" instead of null when the field is empty. The current validation logic incorrectly rejects empty strings as invalid values for required string fields. This fix removes the '|| value == ""' check from the UnmarshalJSON validation, as an empty string is a valid value for a string field and should only validate that the property exists in the JSON payload. Fixes unmarshaling of Device objects from NetBox 4.4.7 webhooks. --- model_device.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model_device.go b/model_device.go index 3f497b0a6..1882e7fd2 100644 --- a/model_device.go +++ b/model_device.go @@ -1962,13 +1962,13 @@ func (o *Device) UnmarshalJSON(data []byte) (err error) { } for _, requiredProperty := range requiredProperties { - if value, exists := allProperties[requiredProperty]; !exists || value == "" { + if _, exists := allProperties[requiredProperty]; !exists { if _, ok := defaultValueFuncMap[requiredProperty]; ok { allProperties[requiredProperty] = defaultValueFuncMap[requiredProperty]() defaultValueApplied = true } } - if value, exists := allProperties[requiredProperty]; !exists || value == "" { + if _, exists := allProperties[requiredProperty]; !exists { return fmt.Errorf("no value given for required property %v", requiredProperty) } }