Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic on using <relation> instead of <relation>_id on groupBy #1551

Closed
fredcarle opened this issue Jun 2, 2023 · 0 comments · Fixed by #1579
Closed

Panic on using <relation> instead of <relation>_id on groupBy #1551

fredcarle opened this issue Jun 2, 2023 · 0 comments · Fixed by #1579
Assignees
Labels
bug Something isn't working
Milestone

Comments

@fredcarle
Copy link
Collaborator

% 2023/06/02 03:58:58 http: panic serving 172.17.0.1:35934: runtime error: index out of range [0] with length 0
goroutine 81290 [running]:
net/http.(*conn).serve.func1()
	net/http/server.go:1850 +0xb8
panic({0x119c100, 0x4009f1c030})
	runtime/panic.go:890 +0x260
github.com/sourcenetwork/defradb/core.(*DocumentMapping).FirstIndexOfName(...)
	github.com/sourcenetwork/defradb/core/doc.go:191
github.com/sourcenetwork/defradb/planner/mapper.toGroupBy(...)
	github.com/sourcenetwork/defradb/planner/mapper/mapper.go:999
github.com/sourcenetwork/defradb/planner/mapper.toTargetable(0x0, 0x4009f49c00, 0x400a1362a0)
	github.com/sourcenetwork/defradb/planner/mapper/mapper.go:865 +0x3d4
github.com/sourcenetwork/defradb/planner/mapper.toSelect(0x40006381c0?, 0x0?, 0x4009f49c00, {0x0?, 0x1?})
	github.com/sourcenetwork/defradb/planner/mapper/mapper.go:99 +0x358
github.com/sourcenetwork/defradb/planner/mapper.ToSelect({0x1746c18?, 0x400a1521b0?}, {0x1754920?, 0x4009f6a0a0?}, 0x2522968?)
	github.com/sourcenetwork/defradb/planner/mapper/mapper.go:35 +0x68
github.com/sourcenetwork/defradb/planner.(*Planner).newPlan(0x400a153950, {0x10779e0?, 0x4009f49c00?})
	github.com/sourcenetwork/defradb/planner/planner.go:120 +0x27c
github.com/sourcenetwork/defradb/planner.(*Planner).newPlan(0x400a153950, {0xf60800?, 0x400a1538f0?})
	github.com/sourcenetwork/defradb/planner/planner.go:117 +0x1b4
github.com/sourcenetwork/defradb/planner.(*Planner).newPlan(0x400a153950, {0xf60900?, 0x4009f6af50?})
	github.com/sourcenetwork/defradb/planner/planner.go:106 +0x144
github.com/sourcenetwork/defradb/planner.(*Planner).makePlan(0x400a2f8c18?, {0xf60900?, 0x4009f6af50?})
	github.com/sourcenetwork/defradb/planner/planner.go:172 +0x28
github.com/sourcenetwork/defradb/planner.(*Planner).RunRequest(0x4009f6a050?, {0x1746c18, 0x400a1521b0}, 0x4009f6af50)
	github.com/sourcenetwork/defradb/planner/planner.go:474 +0x50
github.com/sourcenetwork/defradb/db.(*db).execRequest(0x4000624000, {0x1746c18?, 0x400a1521b0}, {0x40006b7980, 0x34}, {0x1754920?, 0x4009f6a0a0})
	github.com/sourcenetwork/defradb/db/request.go:53 +0x388
github.com/sourcenetwork/defradb/db.(*implicitTxnDB).ExecRequest(0x4000010110, {0x1746c18, 0x400a1521b0}, {0x40006b7980, 0x34})
	github.com/sourcenetwork/defradb/db/txn_db.go:44 +0x180
github.com/sourcenetwork/defradb/api/http.execGQLHandler({0x17432a0, 0x4009f74040}, 0x4009f48200)
	github.com/sourcenetwork/defradb/api/http/handlerfuncs.go:148 +0x5b4
github.com/sourcenetwork/defradb/api/http.(*handler).handle.func1({0x17432a0, 0x4009f74040}, 0x4009f48100)
	github.com/sourcenetwork/defradb/api/http/handler.go:86 +0x2e0
net/http.HandlerFunc.ServeHTTP(0x102f340?, {0x17432a0?, 0x4009f74040?}, 0x400a1d4005?)
	net/http/server.go:2109 +0x38
github.com/go-chi/chi/v5.(*Mux).routeHTTP(0x400007d740, {0x17432a0, 0x4009f74040}, 0x4009f48100)
	github.com/go-chi/chi/v5@v5.0.8/mux.go:444 +0x22c
net/http.HandlerFunc.ServeHTTP(0x1159d80?, {0x17432a0?, 0x4009f74040?}, 0x0?)
	net/http/server.go:2109 +0x38
github.com/sourcenetwork/defradb/api/http.loggerMiddleware.func1({0x1744d10?, 0x4000728000}, 0x4009f48100)
	github.com/sourcenetwork/defradb/api/http/logger.go:57 +0xbc
net/http.HandlerFunc.ServeHTTP(0x40008860a0?, {0x1744d10?, 0x4000728000?}, 0x4009f48100?)
	net/http/server.go:2109 +0x38
github.com/go-chi/cors.(*Cors).Handler.func1({0x1744d10, 0x4000728000}, 0x4009f48100)
	github.com/go-chi/cors@v1.2.1/cors.go:228 +0x1e4
net/http.HandlerFunc.ServeHTTP(0x1746b70?, {0x1744d10?, 0x4000728000?}, 0x225df90?)
	net/http/server.go:2109 +0x38
github.com/go-chi/chi/v5.(*Mux).ServeHTTP(0x400007d740, {0x1744d10, 0x4000728000}, 0x4009f48000)
	github.com/go-chi/chi/v5@v5.0.8/mux.go:90 +0x308
net/http.serverHandler.ServeHTTP({0x173e610?}, {0x1744d10, 0x4000728000}, 0x4009f48000)
	net/http/server.go:2947 +0x2cc
net/http.(*conn).serve(0x400058f720, {0x1746c18, 0x4000804870})
	net/http/server.go:1991 +0x544
created by net/http.(*Server).Serve
	net/http/server.go:3102 +0x43c
@fredcarle fredcarle added the bug Something isn't working label Jun 2, 2023
@fredcarle fredcarle added this to the DefraDB v0.6 milestone Jun 2, 2023
@shahzadlone shahzadlone self-assigned this Jun 15, 2023
shahzadlone added a commit to shahzadlone/defradb that referenced this issue Feb 23, 2024
Resolves sourcenetwork#1578
Resolves sourcenetwork#1551
Part-of: sourcenetwork#1279

## Description
- Add some tests of existing object_id functionality.
- Add implementation for groupBy alias.
- Add tests for groupBy alias ability.
- Fix the previous panic using alias, with more user friendly error.
- Add tests for panic fix.
- Make a const for `_id`.
- Schema Test to ensure the field we want to alias exists (even though
it actually existed from before)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants