Skip to content

Conversation

@mhmtszr
Copy link
Contributor

@mhmtszr mhmtszr commented Aug 3, 2022

We can't see the actual errors of our batch write request. It creates new error and this error does not contain any information about the error return fmt.Sprintf("kafka write errors (%d/%d)", err.Count(), len(err)). We need to see the detail of the error.

Issue thread: #957

Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@mhmtszr
Copy link
Contributor Author

mhmtszr commented Aug 12, 2022

Hi @achille-roussel, are we going to merge this pr?

error.go Outdated
func (err WriteErrors) Error() string {
return fmt.Sprintf("kafka write errors (%d/%d)", err.Count(), len(err))
var sb strings.Builder
for i, writeError := range err {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can write error ever be nil here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think so, if err is empty then it will never execute it what do you think? @rhansen2

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible for one element of the array to be nil?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on what's documented here I believe we have to handle the case when an item in the array is nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhansen2 thanks you are right, I added validation of that.

@rhansen2 rhansen2 self-assigned this Aug 19, 2022
error.go Outdated
if writeError == nil {
continue
}
fmt.Fprintf(&sb, "Message %d: %s \n", i, writeError.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one list nit, it looks like the individual errors are at batch level not individual message level, Message here might be a bit misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhansen2 I removed the string builder part, instead of that I used a slice to be cleaner what do you think about it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mhmtszr This all looks good to me!

@achille-roussel achille-roussel merged commit ba6f442 into segmentio:main Sep 2, 2022
huszkacs pushed a commit to onuruluag/kafka-go that referenced this pull request Sep 8, 2022
* Update WriteErrors error message

* Update error.go

* Handle error nil case

* Update error message for write errors

* preallocate the errors slice

Co-authored-by: Achille <[email protected]>
huszkacs pushed a commit to huszkacs/kafka-go that referenced this pull request Sep 15, 2022
* Update WriteErrors error message

* Update error.go

* Handle error nil case

* Update error message for write errors

* preallocate the errors slice

Co-authored-by: Achille <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants