Skip to content

Commit

Permalink
add same kind of validation used on kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
peczenyj committed May 28, 2024
1 parent 3cd7cf1 commit ca2c5a2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pubsub/rabbitpubsub/rabbit.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ func (o *URLOpener) OpenSubscriptionURL(ctx context.Context, u *url.URL) (*pubsu
for param, value := range u.Query() {
switch param {
case "prefetch_count":
if len(value) == 0 {
if len(value) != 1 || len(value[0]) == 0 {
return nil, fmt.Errorf("open subscription %v: invalid query parameter %q", u, param)

Check warning on line 129 in pubsub/rabbitpubsub/rabbit.go

View check run for this annotation

Codecov / codecov/patch

pubsub/rabbitpubsub/rabbit.go#L129

Added line #L129 was not covered by tests
}
count := value[0]

prefetchCount, err := strconv.Atoi(count)
prefetchCount, err := strconv.Atoi(value[0])
if err != nil {
return nil, fmt.Errorf("open subscription %v: invalid query parameter %q", u, count)
return nil, fmt.Errorf("open subscription %v: invalid query parameter %q: %w", u, param, err)
}

opts.PrefetchCount = &prefetchCount
Expand Down

0 comments on commit ca2c5a2

Please sign in to comment.