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

Change source reporter interfaces to not return errors #3900

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mcastorina
Copy link
Collaborator

Description:

The error was meant to allow the reporter to end scanning, but in practice would only be useful for context cancellations, which sources should be handling anyway. Removing the error simplifies the usage of the interface.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@mcastorina mcastorina requested review from a team as code owners February 11, 2025 09:41
Comment on lines -212 to +209
return reporter.UnitErr(ctx, err)
reporter.UnitErr(ctx, err)
return nil
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the cases where we were returning the reporter error, I changed it to return nil. This would be a behavior change for context cancellations, so maybe we should return ctx.Err() instead. Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that returning ctx.Err() instead is a good idea!

@mcastorina mcastorina requested a review from a team as a code owner February 11, 2025 09:51
Copy link
Collaborator

@rosecodym rosecodym left a comment

Choose a reason for hiding this comment

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

If I understand this PR correctly, it (effectively) removes context cancellation checks from a lot of places (anywhere that used to check for a non-nil error returned from a reporter, and return if one was found). Do we need to re-add them explicitly?

func (c ChanReporter) ChunkOk(ctx context.Context, chunk Chunk) error {
return common.CancellableWrite(ctx, c.Ch, &chunk)
func (c ChanReporter) ChunkOk(ctx context.Context, chunk Chunk) {
_ = common.CancellableWrite(ctx, c.Ch, &chunk)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you leave a comment explaining what kind of errors can get swallowed here and why that's ok to do?

@mcastorina
Copy link
Collaborator Author

If I understand this PR correctly, it (effectively) removes context cancellation checks from a lot of places (anywhere that used to check for a non-nil error returned from a reporter, and return if one was found). Do we need to re-add them explicitly?

That's correct. Additionally, it removes confirmation of whether the item was successfully handled. That is the main tradeoff of this change. The argument is that sources shouldn't need to care whether the item was handled or not.

They do need to be context aware, though.

@rosecodym
Copy link
Collaborator

If I understand this PR correctly, it (effectively) removes context cancellation checks from a lot of places (anywhere that used to check for a non-nil error returned from a reporter, and return if one was found). Do we need to re-add them explicitly?

That's correct. Additionally, it removes confirmation of whether the item was successfully handled. That is the main tradeoff of this change. The argument is that sources shouldn't need to care whether the item was handled or not.

They do need to be context aware, though.

Yep, so then should this PR re-add the (implicit) context cancellation checks that it's removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants