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

internal/driver: return an error on failed source fetching #865

Closed

Conversation

odeke-em
Copy link

This change inverts checks to ensure that we return a wrapped fs.ErrNotExist error if we completely fail to find a source fetcher, instead of panicking.

Fixes #863

This change inverts checks to ensure that we return
a wrapped fs.ErrNotExist error if we completely fail
to find a source fetcher, instead of panicking.

Fixes google#863
@odeke-em
Copy link
Author

Kind /cc @aalexand @ghemawat

@aalexand
Copy link
Collaborator

I sent #864 earlier today.

@odeke-em
Copy link
Author

Oh cool, thanks @aalexand! Could we perhaps copy over and adapt the isolated test that I've crafted to prevent regressions?

func TestFetchDoesNotPanicOnMissingSource(t *testing.T) {
	_, _, err := fetch("non-existent-source", 10*time.Millisecond, 10*time.Millisecond, nil, http.DefaultTransport)
	if err == nil {
		t.Fatal("expected a non-nil error")
	}
	if g, w := err, fs.ErrNotExist; !errors.Is(g, w) {
		t.Fatalf("mismatched type: got %T, want %T", g, w)
	}
}

@aalexand
Copy link
Collaborator

Oh cool, thanks @aalexand! Could we perhaps copy over and adapt the isolated test that I've crafted to prevent regressions?

func TestFetchDoesNotPanicOnMissingSource(t *testing.T) {
	_, _, err := fetch("non-existent-source", 10*time.Millisecond, 10*time.Millisecond, nil, http.DefaultTransport)
	if err == nil {
		t.Fatal("expected a non-nil error")
	}
	if g, w := err, fs.ErrNotExist; !errors.Is(g, w) {
		t.Fatalf("mismatched type: got %T, want %T", g, w)
	}
}

My PR added a test already.

@odeke-em
Copy link
Author

Alright, thanks!

@odeke-em odeke-em closed this May 24, 2024
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.

panics if profile is not found
2 participants