Skip to content

Commit fcf0636

Browse files
authored
[3.2.4 Backport] CBG-4585: Return Invalid JSON error via OIDC discovery (#7461)
1 parent fb2626d commit fcf0636

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

auth/oidc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ func (op *OIDCProvider) fetchCustomProviderConfig(ctx context.Context, discovery
517517
}
518518

519519
if err := base.JSONUnmarshal(bodyBytes, &metadata); err != nil {
520+
err = base.ErrInvalidJSON
520521
base.InfofCtx(ctx, base.KeyAuth, "Error parsing body during discovery sync: %v", err)
521522
return ProviderMetadata{}, MaxProviderConfigSyncInterval, false, err
522523
}

base/error.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ var (
7777

7878
// ErrMaxSequenceReleasedExceeded is returned when the maximum number of sequences to be released as part of nextSequenceGreaterThan is exceeded
7979
ErrMaxSequenceReleasedExceeded = &sgError{"Maximum number of sequences to release to catch up with document sequence exceeded"}
80+
81+
// ErrInvalidJSON is returned when the JSON being unmarshalled cannot be parsed.
82+
ErrInvalidJSON = HTTPErrorf(http.StatusBadRequest, "Invalid JSON")
8083
)
8184

8285
func (e *sgError) Error() string {
@@ -249,7 +252,8 @@ func IsTemporaryKvError(err error) bool {
249252
gocb.ErrTimeout, // SDK op timeout. Wrapped by gocb.ErrAmbiguousTimeout, gocb.ErrUnambiguousTimeout,
250253
gocb.ErrOverload, // SDK client-side pipeline queue full, request was not submitted to server
251254
gocb.ErrTemporaryFailure, // Couchbase Server returned temporary failure error
252-
gocb.ErrCircuitBreakerOpen} // SDK client-side circuit breaker blocked request
255+
gocb.ErrCircuitBreakerOpen, // SDK client-side circuit breaker blocked request
256+
}
253257

254258
// iterate through to check incoming error is one of them
255259
for _, tempKVErr := range temporaryKVError {

0 commit comments

Comments
 (0)