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

fix(api.Body): fix bug that returns error when getting a peers body #533

Merged
merged 2 commits into from
Sep 4, 2018

Conversation

ramfox
Copy link
Member

@ramfox ramfox commented Aug 30, 2018

closes #532

But only in the sense that it fixes the immediate bug, not necessarily the underlying structure that may need to change.

Asking for this to be merged tho, since without it the frontend freaks out when trying to get a peer's dataset body

@ramfox ramfox requested a review from dustmop August 30, 2018 22:46
@ghost ghost assigned ramfox Aug 30, 2018
@ghost ghost added the in progress label Aug 30, 2018
@ramfox ramfox requested a review from b5 August 30, 2018 22:46
api/datasets.go Outdated
@@ -646,7 +646,13 @@ func (h DatasetHandlers) bodyHandler(w http.ResponseWriter, r *http.Request) {
}

if err := repo.CanonicalizeDatasetRef(h.repo, &d); err != nil {
util.WriteErrResponse(w, http.StatusInternalServerError, err)
// TODO: look through lib.LookupBody and see if we can refactor so it takes a datasetRef rather than just a path.
Copy link
Contributor

Choose a reason for hiding this comment

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

This bug is my fault (sorry!), but this is not the right fix. The semantics of CanonicalizeDatasetRef are weird because it's now basically doing two things. If the err returned is equal to repo.ErrNotFound, it means the ref was canonicalized but the dataset doesn't exist in the local repo. I made this change but forgot to update all the callers (whoops!). The correct thing to do here is to only send StateInternalServerError if err != nil && err != repo.ErrNotFound. As long as the dataset is remote, the rest of this code will handle it just fine by continuing onto LookupBody.

Copy link
Member Author

Choose a reason for hiding this comment

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

dope thanks!!!!

Copy link
Contributor

@dustmop dustmop left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@ramfox ramfox merged commit f976e3c into master Sep 4, 2018
@ghost ghost removed the in progress label Sep 4, 2018
@ramfox ramfox deleted the body branch September 4, 2018 14:29
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.

Bug: /body endpoint returns malformed data when returning peer's body
2 participants