Skip to content

Commit

Permalink
check invalid queue names
Browse files Browse the repository at this point in the history
  • Loading branch information
gfr10598 committed Sep 20, 2018
1 parent fdd5b31 commit 8fbbdfa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions cloud/tq/tq.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (

// Errors associated with Queuing
var (
ErrNilClient = errors.New("nil http client not allowed")
ErrMoreTasks = errors.New("queue has tasks pending")
ErrNilClient = errors.New("nil http client not allowed")
ErrMoreTasks = errors.New("queue has tasks pending")
ErrInvalidQueueName = errors.New("invalid queue name")
)

// QueueHandler is much like tq.Queuer, but for a single queue. We want
Expand All @@ -50,6 +51,9 @@ func NewQueueHandler(config cloud.Config, queue string) (*QueueHandler, error) {
return nil, ErrNilClient
}

if strings.TrimSpace(queue) != queue {
return nil, ErrInvalidQueueName
}
return &QueueHandler{config, queue}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion rex/rex.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (rex *ReprocessingExecutor) waitForParsing(t *state.Task, terminate <-chan
qh, err := tq.NewQueueHandler(rex.Config, t.Queue)
if err != nil {
metrics.FailCount.WithLabelValues("NewQueueHandler")
t.SetError(err, "NewQueueHandler")
t.SetError(err, "NewQueueHandler: "+t.Name)
return
}
log.Println("Wait for empty queue ", qh.Queue)
Expand Down

0 comments on commit 8fbbdfa

Please sign in to comment.