Skip to content

Commit

Permalink
ingest WriteKeyStreamLocator: better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Nov 9, 2024
1 parent dfbba74 commit cd0232b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ingest/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ type StreamCredentials struct {
IngestType IngestType `json:"ingestType"`
}

func (sc *StreamCredentials) String() string {
return fmt.Sprintf("[slug: %s][domain: %s][writeKey: %s][ingestType: %s]", sc.Slug, sc.Domain, maskWriteKey(sc.WriteKey), sc.IngestType)
}

func NewRouter(appContext *Context, partitionSelector kafkabase.PartitionSelector) *Router {
base := appbase.NewRouterBase(appContext.config.Config, []string{
"/health",
Expand Down Expand Up @@ -562,9 +566,9 @@ func (r *Router) WriteKeyStreamLocator(loc *StreamCredentials, _ bool) *StreamWi
binding := r.repository.GetData().getStreamByKeyId(parts[0])
if binding != nil {
if loc.IngestType != IngestTypeWriteKeyDefined && binding.KeyType != string(loc.IngestType) {
r.Errorf("invalid key type: found %s, expected %s", binding.KeyType, loc.IngestType)
r.Errorf("[stream: %s]%s invalid key type found %s, expected %s", binding.StreamId, loc.String(), binding.KeyType, loc.IngestType)
} else if !r.checkHash(binding.Hash, parts[1]) {
r.Errorf("invalid key secret")
r.Errorf("[stream: %s]%s invalid key secret", binding.StreamId, loc.String())
} else {
stream := r.repository.GetData().GetStreamById(binding.StreamId)
if stream != nil {
Expand Down

0 comments on commit cd0232b

Please sign in to comment.