riferrei / srclient

Golang Client for Schema Registry
Apache License 2.0
236 stars 70 forks source link

SRClient fails and terminates application on error from schema registry #72

Closed martinhynar closed 2 years ago

martinhynar commented 2 years ago

I just upgraded to srclient v0.5.0 and my application stated to panic on call GetLatestSchema call when schema does not exist.

In access log to schema registry, I see that the return code is 404. The call itself ends with panic and application is terminated.

The application code is quite straight

schema, err = srClient.GetLatestSchema(topic)
if err != nil {
  // logic that installs schema in schema registry
}

However, the error handling is not reached as the application fails with this:

panic: runtime error: makeslice: cap out of range
goroutine 7 [running]:
github.com/riferrei/srclient.createError(0xc000438090, 0xc0021d4000, 0xc000438090)
/go/pkg/mod/github.com/riferrei/srclient@v0.5.0/schemaRegistryClient.go:746 +0x73
github.com/riferrei/srclient.(*SchemaRegistryClient).httpRequest(0xc0002ee000, 0xed1c3d, 0x3, 0xc00034a180, 0x33, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/pkg/mod/github.com/riferrei/srclient@v0.5.0/schemaRegistryClient.go:637 +0x385
github.com/riferrei/srclient.(*SchemaRegistryClient).getVersion(0xc0002ee000, 0xc000354a00, 0x19, 0xed2b18, 0x6, 0xc0021a4230, 0x0, 0x0)
/go/pkg/mod/github.com/riferrei/srclient@v0.5.0/schemaRegistryClient.go:570 +0x155
github.com/riferrei/srclient.(*SchemaRegistryClient).GetLatestSchema(...)
/go/pkg/mod/github.com/riferrei/srclient@v0.5.0/schemaRegistryClient.go:243

Same application code works correctly with v0.4.0

AtakanColak commented 2 years ago

Released v0.5.1

Thank you.

riferrei commented 2 years ago

Thank you for your continuously fantastic support @AtakanColak 🙂

AtakanColak commented 2 years ago

@riferrei No worries but I'd like to express that I'm not using Confluent Schema Registry anymore, and couldn't figure out how to set it on a local docker environment. Hence I don't really have a way of testing the code anymore.

martinhynar commented 2 years ago

I have few scripts that set Confluent stack, you can use/inspire - https://github.com/martinhynar/dockery-dock/tree/master/kafka-stack

I don't use docker-compose file with all services in one place, as I frequently use only subset and it comes handier for me to just fire script.