Add checks for nil in all JetStream API requests in jetstream package.
For example, in upsertConsumer(), a check could be added returning a new error kind:
if resp.ConsumerInfo == nil {
return nil, ErrInvalidJetStreamResponse
}
Package should be scanned for places where API requests are sent, e.g. CRUD operations on streams, consumers, AccountInfo etc.
Use case
While unlikely, it may happen that the server responds to JetStream API requests with unexpected data, neither apiResponse (for errors) nor the actual expected type.
While not common, this can happen e.g. due to server bug and in such cases the client should not panic but simply return an error indicating what happened.
Proposed change
Add checks for
nil
in all JetStream API requests injetstream
package.For example, in upsertConsumer(), a check could be added returning a new error kind:
Package should be scanned for places where API requests are sent, e.g. CRUD operations on streams, consumers,
AccountInfo
etc.Use case
While unlikely, it may happen that the server responds to JetStream API requests with unexpected data, neither
apiResponse
(for errors) nor the actual expected type.While not common, this can happen e.g. due to server bug and in such cases the client should not panic but simply return an error indicating what happened.
https://github.com/nats-io/nats.go/issues/1641 was a motivation for this proposal.
Contribution
No response