wpnpeiris / nats-gateway

S3 API compatible NATS Object Store
10 stars 2 forks source link

panic serving 127.0.0.1:56069: runtime error: invalid memory address or nil pointer dereference goroutine 29 [running]: #8

Closed gedw99 closed 2 weeks ago

gedw99 commented 2 weeks ago

Mac darwin environment....

AWS cli


aws s3 ls s3://bucket1 --endpoint-url=http://localhost:8080

Connection was closed before we received a valid response from endpoint URL: "http://localhost:8080/bucket1?list-type=2&prefix=&delimiter=%2F&encoding-type=url".

All the was cli calls fails with the same error message BTW.

NATS Gateway server

nats-gateway -listen localhost:8080 -nats nats:/127.0.0.1:4222
2024/06/16 14:40:06 Starting NATS Gateway...
2024/06/16 14:40:06 Listening for HTTP requests on localhost:8080
List Objects in bucket bucket1
2024/06/16 14:40:12 http: panic serving 127.0.0.1:56069: runtime error: invalid memory address or nil pointer dereference
goroutine 29 [running]:
net/http.(*conn).serve.func1()
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:1898 +0xb0
panic({0x1068f8b40?, 0x107ac52c0?})
        /opt/homebrew/opt/go/libexec/src/runtime/panic.go:770 +0x124
github.com/wpnpeiris/nats-gateway/internal/s3.(*S3Gateway).ListObjects(0x140001c2f20, {0x106c3e690, 0x140007cc000}, 0x1066bcc90?)
        /Users/apple/workspace/go/src/github.com/nats-gateway/internal/s3/s3-object-handlers.go:43 +0xf4
net/http.HandlerFunc.ServeHTTP(0x140007aa480?, {0x106c3e690?, 0x140007cc000?}, 0x104d8df68?)
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:2166 +0x38
github.com/gorilla/mux.(*Router).ServeHTTP(0x14000394480, {0x106c3e690, 0x140007cc000}, 0x140007aa000)
        /Users/apple/workspace/go/pkg/mod/github.com/gorilla/mux@v1.8.1/mux.go:212 +0x194
net/http.serverHandler.ServeHTTP({0x140007841e0?}, {0x106c3e690?, 0x140007cc000?}, 0x6?)
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:3137 +0xbc
net/http.(*conn).serve(0x1400079e000, {0x106c44078, 0x140007840f0})
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:2039 +0x508
created by net/http.(*Server).Serve in goroutine 104
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:3285 +0x3f0
List Objects in bucket bucket1
2024/06/16 14:40:12 http: panic serving 127.0.0.1:56071: runtime error: invalid memory address or nil pointer dereference
goroutine 32 [running]:
net/http.(*conn).serve.func1()
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:1898 +0xb0
panic({0x1068f8b40?, 0x107ac52c0?})
        /opt/homebrew/opt/go/libexec/src/runtime/panic.go:770 +0x124
github.com/wpnpeiris/nats-gateway/internal/s3.(*S3Gateway).ListObjects(0x140001c2f20, {0x106c3e690, 0x140007cc380}, 0x1066bcc90?)
        /Users/apple/workspace/go/src/github.com/nats-gateway/internal/s3/s3-object-handlers.go:43 +0xf4
net/http.HandlerFunc.ServeHTTP(0x140007aa360?, {0x106c3e690?, 0x140007cc380?}, 0x104d8df68?)
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:2166 +0x38
github.com/gorilla/mux.(*Router).ServeHTTP(0x14000394480, {0x106c3e690, 0x140007cc380}, 0x140007aa120)
        /Users/apple/workspace/go/pkg/mod/github.com/gorilla/mux@v1.8.1/mux.go:212 +0x194
net/http.serverHandler.ServeHTTP({0x14000784360?}, {0x106c3e690?, 0x140007cc380?}, 0x6?)
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:3137 +0xbc
net/http.(*conn).serve(0x1400079e120, {0x106c44078, 0x140007840f0})
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:2039 +0x508
created by net/http.(*Server).Serve in goroutine 104
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:3285 +0x3f0
List Objects in bucket bucket1
2024/06/16 14:40:14 http: panic serving 127.0.0.1:56073: runtime error: invalid memory address or nil pointer dereference
goroutine 114 [running]:
net/http.(*conn).serve.func1()
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:1898 +0xb0
panic({0x1068f8b40?, 0x107ac52c0?})
        /opt/homebrew/opt/go/libexec/src/runtime/panic.go:770 +0x124
github.com/wpnpeiris/nats-gateway/internal/s3.(*S3Gateway).ListObjects(0x140001c2f20, {0x106c3e690, 0x140007cc460}, 0x1066bcc90?)
        /Users/apple/workspace/go/src/github.com/nats-gateway/internal/s3/s3-object-handlers.go:43 +0xf4
net/http.HandlerFunc.ServeHTTP(0x140007aa7e0?, {0x106c3e690?, 0x140007cc460?}, 0x104d8df68?)
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:2166 +0x38
github.com/gorilla/mux.(*Router).ServeHTTP(0x14000394480, {0x106c3e690, 0x140007cc460}, 0x140007aa5a0)
        /Users/apple/workspace/go/pkg/mod/github.com/gorilla/mux@v1.8.1/mux.go:212 +0x194
net/http.serverHandler.ServeHTTP({0x14000784780?}, {0x106c3e690?, 0x140007cc460?}, 0x6?)
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:3137 +0xbc
net/http.(*conn).serve(0x1400079e3f0, {0x106c44078, 0x140007840f0})
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:2039 +0x508
created by net/http.(*Server).Serve in goroutine 104
        /opt/homebrew/opt/go/libexec/src/net/http/server.go:3285 +0x3f0

nats server


nats-server --jetstream --store_dir /Users/apple/workspace/go/src/github.com/nats-gateway/.data --net 127.0.0.1 --port 4222
[12687] 2024/06/14 20:33:19.208988 [INF] Starting nats-server
[12687] 2024/06/14 20:33:19.209577 [INF]   Version:  2.10.16
[12687] 2024/06/14 20:33:19.209581 [INF]   Git:      [not set]
[12687] 2024/06/14 20:33:19.209583 [INF]   Name:     NAO77KBSDDZ5VEQ6SRFQQ7ZO7ZXBMG6TTVRYGLB545MULKFXDICDRYBQ
[12687] 2024/06/14 20:33:19.209588 [INF]   Node:     wBs3sdxq
[12687] 2024/06/14 20:33:19.209590 [INF]   ID:       NAO77KBSDDZ5VEQ6SRFQQ7ZO7ZXBMG6TTVRYGLB545MULKFXDICDRYBQ
[12687] 2024/06/14 20:33:19.210510 [INF] Starting JetStream
[12687] 2024/06/14 20:33:19.211560 [INF]     _ ___ _____ ___ _____ ___ ___   _   __  __
[12687] 2024/06/14 20:33:19.211565 [INF]  _ | | __|_   _/ __|_   _| _ \ __| /_\ |  \/  |
[12687] 2024/06/14 20:33:19.211567 [INF] | || | _|  | | \__ \ | | |   / _| / _ \| |\/| |
[12687] 2024/06/14 20:33:19.211568 [INF]  \__/|___| |_| |___/ |_| |_|_\___/_/ \_\_|  |_|
[12687] 2024/06/14 20:33:19.211569 [INF] 
[12687] 2024/06/14 20:33:19.211572 [INF]          https://docs.nats.io/jetstream
[12687] 2024/06/14 20:33:19.211573 [INF] 
[12687] 2024/06/14 20:33:19.211574 [INF] ---------------- JETSTREAM ----------------
[12687] 2024/06/14 20:33:19.211577 [INF]   Max Memory:      12.00 GB
[12687] 2024/06/14 20:33:19.211578 [INF]   Max Storage:     78.63 GB
[12687] 2024/06/14 20:33:19.211580 [INF]   Store Directory: "/Users/apple/workspace/go/src/github.com/nats-gateway/.data/jetstream"
[12687] 2024/06/14 20:33:19.211583 [INF] -------------------------------------------
[12687] 2024/06/14 20:33:19.212010 [INF] Listening for client connections on 127.0.0.1:4222
[12687] 2024/06/14 20:33:19.212021 [INF] Server is ready
wpnpeiris commented 2 weeks ago

@gedw99 thanks for trying out the API. The issue should be fixed now. (It is still a poc, a lot to improve)

gedw99 commented 2 weeks ago

Yep I know it’s a pic :)

thanks for fixing.

gedw99 commented 2 weeks ago

I can confirm this is now fixed for me.

thanks @wpnpeiris

gedw99 commented 2 weeks ago

close at will :)

wpnpeiris commented 2 weeks ago

close as @gedw99 verified.