-
Notifications
You must be signed in to change notification settings - Fork 26
fix(destinations): Propagate write errors #461
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,21 +90,23 @@ func (s *DestinationServer) Write2(msg pb.Destination_Write2Server) error { | |
| if err == io.EOF { | ||
| close(resources) | ||
| if err := eg.Wait(); err != nil { | ||
| return fmt.Errorf("got EOF. failed to wait for plugin: %w", err) | ||
| return fmt.Errorf("plugin write failed: %w", err) | ||
| } | ||
| return msg.SendAndClose(&pb.Write2_Response{}) | ||
| } | ||
| close(resources) | ||
| if err := eg.Wait(); err != nil { | ||
| s.Logger.Error().Err(err).Msg("got error. failed to wait for plugin") | ||
| return fmt.Errorf("plugin write failed: %w", err) | ||
| } | ||
| return fmt.Errorf("failed to receive msg: %w", err) | ||
| } | ||
| var resource schema.DestinationResource | ||
| if err := json.Unmarshal(r.Resource, &resource); err != nil { | ||
| close(resources) | ||
| if err := eg.Wait(); err != nil { | ||
| s.Logger.Error().Err(err).Msg("failed to unmarshal resource. failed to wait for plugin") | ||
| // log the unmarshal error so we don't lose that information, but return the write error as that's the first one that occurred | ||
| s.Logger.Error().Err(err).Msg("failed to unmarshal resource") | ||
| return fmt.Errorf("plugin write failed: %w", err) | ||
| } | ||
| return status.Errorf(codes.InvalidArgument, "failed to unmarshal resource: %v", err) | ||
| } | ||
|
|
@@ -113,7 +115,7 @@ func (s *DestinationServer) Write2(msg pb.Destination_Write2Server) error { | |
| case <-ctx.Done(): | ||
| close(resources) | ||
| if err := eg.Wait(); err != nil { | ||
| s.Logger.Error().Err(err).Msg("failed to wait") | ||
| return fmt.Errorf("plugin write failed: %w", err) | ||
| } | ||
| return ctx.Err() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are losing the information from the original JSON unmarshal error here now - that's why the previous implementation only logged the
Waiterror and then returned the original JSON unmarshal error. Maybe we should keep it that way? I'm open to other options too, but we shouldn't drop that error without logging it at leastThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not sure. I actually think we should return a list of errors, but that's a bigger change.
I think the
Writeerror is the first one that occurred so it makes more sense to return it.I'll add a log for the unmarshal error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#487 should allow us to report both