Skip to content

Commit d83355b

Browse files
authored
Merge pull request #2782 from matthewbinshtok/binshtok/fix-validate-retry-config-error-msg
[grpc-js] Fix error messages in `serviceConfig` validation
2 parents 1faf6ce + d6925d9 commit d83355b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

packages/grpc-js/src/service-config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function validateRetryPolicy(obj: any): RetryPolicy {
143143
!DURATION_REGEX.test(obj.initialBackoff)
144144
) {
145145
throw new Error(
146-
'Invalid method config retry policy: initialBackoff must be a string consisting of a positive integer followed by s'
146+
'Invalid method config retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s'
147147
);
148148
}
149149
if (
@@ -152,7 +152,7 @@ function validateRetryPolicy(obj: any): RetryPolicy {
152152
!DURATION_REGEX.test(obj.maxBackoff)
153153
) {
154154
throw new Error(
155-
'Invalid method config retry policy: maxBackoff must be a string consisting of a positive integer followed by s'
155+
'Invalid method config retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s'
156156
);
157157
}
158158
if (
@@ -228,18 +228,18 @@ function validateHedgingPolicy(obj: any): HedgingPolicy {
228228
if (typeof value === 'number') {
229229
if (!Object.values(Status).includes(value)) {
230230
throw new Error(
231-
'Invlid method config hedging policy: nonFatalStatusCodes value not in status code range'
231+
'Invalid method config hedging policy: nonFatalStatusCodes value not in status code range'
232232
);
233233
}
234234
} else if (typeof value === 'string') {
235235
if (!Object.values(Status).includes(value.toUpperCase())) {
236236
throw new Error(
237-
'Invlid method config hedging policy: nonFatalStatusCodes value not a status code name'
237+
'Invalid method config hedging policy: nonFatalStatusCodes value not a status code name'
238238
);
239239
}
240240
} else {
241241
throw new Error(
242-
'Invlid method config hedging policy: nonFatalStatusCodes value must be a string or number'
242+
'Invalid method config hedging policy: nonFatalStatusCodes value must be a string or number'
243243
);
244244
}
245245
}

packages/grpc-js/test/test-retry-config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ const RETRY_TEST_CASES: TestCase[] = [
101101
retryableStatusCodes: [14],
102102
},
103103
error:
104-
/retry policy: initialBackoff must be a string consisting of a positive integer followed by s/,
104+
/retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s/,
105105
},
106106
{
107107
description: 'a non-numeric initialBackoff',
108108
config: { ...validRetryConfig, initialBackoff: 'abcs' },
109109
error:
110-
/retry policy: initialBackoff must be a string consisting of a positive integer followed by s/,
110+
/retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s/,
111111
},
112112
{
113113
description: 'an initialBackoff without an s',
114114
config: { ...validRetryConfig, initialBackoff: '123' },
115115
error:
116-
/retry policy: initialBackoff must be a string consisting of a positive integer followed by s/,
116+
/retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s/,
117117
},
118118
{
119119
description: 'omitted maxBackoff',
@@ -124,19 +124,19 @@ const RETRY_TEST_CASES: TestCase[] = [
124124
retryableStatusCodes: [14],
125125
},
126126
error:
127-
/retry policy: maxBackoff must be a string consisting of a positive integer followed by s/,
127+
/retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s/,
128128
},
129129
{
130130
description: 'a non-numeric maxBackoff',
131131
config: { ...validRetryConfig, maxBackoff: 'abcs' },
132132
error:
133-
/retry policy: maxBackoff must be a string consisting of a positive integer followed by s/,
133+
/retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s/,
134134
},
135135
{
136136
description: 'an maxBackoff without an s',
137137
config: { ...validRetryConfig, maxBackoff: '123' },
138138
error:
139-
/retry policy: maxBackoff must be a string consisting of a positive integer followed by s/,
139+
/retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s/,
140140
},
141141
{
142142
description: 'omitted backoffMultiplier',

0 commit comments

Comments
 (0)