From 4f76fef0a06f95c60467aacf9434b76950ad72b3 Mon Sep 17 00:00:00 2001 From: Pieter Loubser Date: Tue, 20 Aug 2024 13:50:48 +0100 Subject: [PATCH] (#119) Fix sampleFrequency parsing in update function When a consumer config is created with sampleFrequency as 0%, the consumer will store this as an empty string. We will now check the value of sampleFrequency before trying to parse the string. --- jetstream/resource_jetstream_consumer.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jetstream/resource_jetstream_consumer.go b/jetstream/resource_jetstream_consumer.go index eba39d0..6a4463d 100644 --- a/jetstream/resource_jetstream_consumer.go +++ b/jetstream/resource_jetstream_consumer.go @@ -415,10 +415,13 @@ func resourceConsumerUpdate(d *schema.ResourceData, m any) error { return err } - s := strings.TrimSuffix(cons.SampleFrequency(), "%") - freq, err := strconv.Atoi(s) - if err != nil { - return fmt.Errorf("failed to parse consumer sampling configuration: %v", err) + freq := 0 + if len(cons.SampleFrequency()) > 0 { + s := strings.TrimSuffix(cons.SampleFrequency(), "%") + freq, err = strconv.Atoi(s) + if err != nil { + return fmt.Errorf("failed to parse consumer sampling configuration: %v", err) + } } opts := []jsm.ConsumerOption{