Skip to content

Aggregating relation with a secondary index panics #2829

Open

Description

Found by David, e.g.:

type Foo {
  name: String @index(unique: true)
  bar: [Bar] 
}

type Bar {
  points: Int
  foo: Foo @index
}

// create docs

query {
  Bar( groupBy: [ bar_id ], filter: { bar_id: { _eq: "bae-d53e923f-0aed-5f0b-b179-274c32fe66a1" } } ) {
    foo { _docID }
    _sum( _group: { field: points } )
  }
}

Result:

 panic: runtime error: index out of range [1] with length 1
 
 -> github.com/sourcenetwork/defradb/internal/db/fetcher.(*IndexFetcher).newIndexDataStoreKeyWithValues
 ->   github.com/sourcenetwork/defradb/internal/db/fetcher/indexer_iterators.go:530

    github.com/sourcenetwork/defradb/internal/db/fetcher.(*IndexFetcher).newPrefixIndexIterator
      github.com/sourcenetwork/defradb/internal/db/fetcher/indexer_iterators.go:457
    github.com/sourcenetwork/defradb/internal/db/fetcher.(*IndexFetcher).createIndexIterator
      github.com/sourcenetwork/defradb/internal/db/fetcher/indexer_iterators.go:561
    github.com/sourcenetwork/defradb/internal/db/fetcher.(*IndexFetcher).Init
...

Example above is a rough obfuscation of a partner query, @AndrewSisley or David can provide the original if required but please don't add it to the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area/queryRelated to the query componentbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions