Merge branch 'master' into translation-coordinator

This commit is contained in:
Kuba Podgórski 2020-07-11 19:22:48 +02:00 committed by GitHub
commit 51ba2492e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -53,8 +53,7 @@ var (
ErrInvalidView = errors.New("invalid view")
ErrInvalidCacheType = errors.New("invalid cache type")
ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9_-]* and contain at most 230 characters")
ErrLabel = errors.New("invalid row or column label, must match [A-Za-z0-9_-]")
ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9_-]* and contain at most 230 characters")
// ErrFragmentNotFound is returned when a fragment does not exist.
ErrFragmentNotFound = errors.New("fragment not found")

View file

@ -17,6 +17,7 @@ package pilosa
import (
"context"
"encoding/json"
"regexp"
"sync"
"time"
@ -24,6 +25,8 @@ import (
"github.com/pkg/errors"
)
var txIDRegexp = regexp.MustCompile("^[A-Za-z0-9_-]*$")
// Transaction contains information related to a block of work that
// needs to be tracked and spans multiple API calls.
type Transaction struct {
@ -93,6 +96,10 @@ func (tm *TransactionManager) Start(ctx context.Context, id string, timeout time
tm.mu.Lock()
defer tm.mu.Unlock()
if !txIDRegexp.Match([]byte(id)) {
return nil, errors.New("invalid transaction ID, must match [A-Za-z0-9_-]")
}
trnsMap, err := tm.store.List()
if err != nil {
return nil, errors.Wrap(err, "listing transactions in Start")