Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks for empty response in JetStream API calls #1642

Open
piotrpio opened this issue Jun 6, 2024 · 2 comments
Open

Add checks for empty response in JetStream API calls #1642

piotrpio opened this issue Jun 6, 2024 · 2 comments
Assignees
Labels
accepted The defect or proposal as been accepted enhancement Enhancement to existing functionality help wanted proposal Enhancement idea or proposal

Comments

@piotrpio
Copy link
Collaborator

piotrpio commented Jun 6, 2024

Proposed change

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.

#1641 was a motivation for this proposal.

Contribution

No response

@piotrpio piotrpio added enhancement Enhancement to existing functionality proposal Enhancement idea or proposal accepted The defect or proposal as been accepted help wanted labels Jun 6, 2024
@areknoster
Copy link

@piotrpio I'd be happy to implement that, I don't have access to assign myself to the issue

@piotrpio
Copy link
Collaborator Author

piotrpio commented Jun 7, 2024

Sorry about that! I assigned you now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The defect or proposal as been accepted enhancement Enhancement to existing functionality help wanted proposal Enhancement idea or proposal
Projects
None yet
Development

No branches or pull requests

2 participants