Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Handle missing values when building a routing key #48

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

martin-sucha
Copy link
Collaborator

This fixes the following panic when not enough bound values are present:

panic: runtime error: index out of range [0] with length 0
goroutine 663 [running]:
github.com/gocql/gocql.createRoutingKey(0xc0004b4000, {0x0, 0x0, 0xc000042360?})
	/go/pkg/mod/github.com/kiwicom/[email protected]/session.go:2097 +0x58d
github.com/gocql/gocql.(*Query).GetRoutingKey(0xc00089e8c0)
	/go/pkg/mod/github.com/kiwicom/[email protected]/session.go:1231 +0x446
github.com/gocql/gocql.(*tokenAwareHostPolicy).Pick(0xc0000f2380, {0x195da60, 0xc00089e8c0})
	/go/pkg/mod/github.com/kiwicom/[email protected]/policies.go:574 +0x64
github.com/gocql/gocql.(*queryExecutor).executeQuery(0xc000a12060, {0x195da60, 0xc00089e8c0})
	/go/pkg/mod/github.com/kiwicom/[email protected]/query_executor.go:67 +0x96
github.com/gocql/gocql.(*Session).executeQuery(0xc00051fb00, 0x3?)
	/go/pkg/mod/github.com/kiwicom/[email protected]/session.go:548 +0x145
github.com/gocql/gocql.(*Query).Iter(0xc00089e8c0)
	/go/pkg/mod/github.com/kiwicom/[email protected]/session.go:1372 +0x13f
github.com/scylladb/gocqlx/v2.(*Queryx).Iter(...)
	/go/pkg/mod/github.com/scylladb/gocqlx/[email protected]/queryx.go:344

This fixes the following panic when not enough bound values are present:

```
panic: runtime error: index out of range [0] with length 0
goroutine 663 [running]:
github.com/gocql/gocql.createRoutingKey(0xc0004b4000, {0x0, 0x0, 0xc000042360?})
	/go/pkg/mod/github.com/kiwicom/[email protected]/session.go:2097 +0x58d
github.com/gocql/gocql.(*Query).GetRoutingKey(0xc00089e8c0)
	/go/pkg/mod/github.com/kiwicom/[email protected]/session.go:1231 +0x446
github.com/gocql/gocql.(*tokenAwareHostPolicy).Pick(0xc0000f2380, {0x195da60, 0xc00089e8c0})
	/go/pkg/mod/github.com/kiwicom/[email protected]/policies.go:574 +0x64
github.com/gocql/gocql.(*queryExecutor).executeQuery(0xc000a12060, {0x195da60, 0xc00089e8c0})
	/go/pkg/mod/github.com/kiwicom/[email protected]/query_executor.go:67 +0x96
github.com/gocql/gocql.(*Session).executeQuery(0xc00051fb00, 0x3?)
	/go/pkg/mod/github.com/kiwicom/[email protected]/session.go:548 +0x145
github.com/gocql/gocql.(*Query).Iter(0xc00089e8c0)
	/go/pkg/mod/github.com/kiwicom/[email protected]/session.go:1372 +0x13f
github.com/scylladb/gocqlx/v2.(*Queryx).Iter(...)
	/go/pkg/mod/github.com/scylladb/gocqlx/[email protected]/queryx.go:344
```
@martin-sucha martin-sucha merged commit 1e364b6 into master Mar 1, 2024
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants