From fc5bee791d6eee950ee52350ab53f5edb67af66f Mon Sep 17 00:00:00 2001 From: Matthew Binshtok Date: Wed, 26 Jun 2024 10:15:30 -0400 Subject: [PATCH 1/2] fix error msgs in service config validation --- packages/grpc-js/src/service-config.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/grpc-js/src/service-config.ts b/packages/grpc-js/src/service-config.ts index b0d0d557..db1e30ec 100644 --- a/packages/grpc-js/src/service-config.ts +++ b/packages/grpc-js/src/service-config.ts @@ -143,7 +143,7 @@ function validateRetryPolicy(obj: any): RetryPolicy { !DURATION_REGEX.test(obj.initialBackoff) ) { throw new Error( - 'Invalid method config retry policy: initialBackoff must be a string consisting of a positive integer followed by s' + 'Invalid method config retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s' ); } if ( @@ -152,7 +152,7 @@ function validateRetryPolicy(obj: any): RetryPolicy { !DURATION_REGEX.test(obj.maxBackoff) ) { throw new Error( - 'Invalid method config retry policy: maxBackoff must be a string consisting of a positive integer followed by s' + 'Invalid method config retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s' ); } if ( @@ -228,18 +228,18 @@ function validateHedgingPolicy(obj: any): HedgingPolicy { if (typeof value === 'number') { if (!Object.values(Status).includes(value)) { throw new Error( - 'Invlid method config hedging policy: nonFatalStatusCodes value not in status code range' + 'Invalid method config hedging policy: nonFatalStatusCodes value not in status code range' ); } } else if (typeof value === 'string') { if (!Object.values(Status).includes(value.toUpperCase())) { throw new Error( - 'Invlid method config hedging policy: nonFatalStatusCodes value not a status code name' + 'Invalid method config hedging policy: nonFatalStatusCodes value not a status code name' ); } } else { throw new Error( - 'Invlid method config hedging policy: nonFatalStatusCodes value must be a string or number' + 'Invalid method config hedging policy: nonFatalStatusCodes value must be a string or number' ); } } From d6925d914124d0703659c01d720ac37f57630c43 Mon Sep 17 00:00:00 2001 From: Matthew Binshtok Date: Wed, 26 Jun 2024 14:17:03 -0400 Subject: [PATCH 2/2] fix tests --- packages/grpc-js/test/test-retry-config.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/grpc-js/test/test-retry-config.ts b/packages/grpc-js/test/test-retry-config.ts index 77952e66..0e110d1d 100644 --- a/packages/grpc-js/test/test-retry-config.ts +++ b/packages/grpc-js/test/test-retry-config.ts @@ -101,19 +101,19 @@ const RETRY_TEST_CASES: TestCase[] = [ retryableStatusCodes: [14], }, error: - /retry policy: initialBackoff must be a string consisting of a positive integer followed by s/, + /retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s/, }, { description: 'a non-numeric initialBackoff', config: { ...validRetryConfig, initialBackoff: 'abcs' }, error: - /retry policy: initialBackoff must be a string consisting of a positive integer followed by s/, + /retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s/, }, { description: 'an initialBackoff without an s', config: { ...validRetryConfig, initialBackoff: '123' }, error: - /retry policy: initialBackoff must be a string consisting of a positive integer followed by s/, + /retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s/, }, { description: 'omitted maxBackoff', @@ -124,19 +124,19 @@ const RETRY_TEST_CASES: TestCase[] = [ retryableStatusCodes: [14], }, error: - /retry policy: maxBackoff must be a string consisting of a positive integer followed by s/, + /retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s/, }, { description: 'a non-numeric maxBackoff', config: { ...validRetryConfig, maxBackoff: 'abcs' }, error: - /retry policy: maxBackoff must be a string consisting of a positive integer followed by s/, + /retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s/, }, { description: 'an maxBackoff without an s', config: { ...validRetryConfig, maxBackoff: '123' }, error: - /retry policy: maxBackoff must be a string consisting of a positive integer followed by s/, + /retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s/, }, { description: 'omitted backoffMultiplier',