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

Return a 409 when attempting to create a bucket that already exists #805

Merged
merged 1 commit into from
Jun 2, 2022

Conversation

dnerdy
Copy link
Contributor

@dnerdy dnerdy commented Jun 2, 2022

This PR updates createBucketByPost to return a 409 response when the
bucket being created already exists. This matches the behavior of the
GCS API.

Fixes #804.

This PR updates createBucketByPost to return a 409 response when the
bucket being created already exists. This matches the behavior of the
GCS API.

Fixes fsouza#804.
Copy link
Owner

@fsouza fsouza 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 contributing!

@@ -70,6 +71,18 @@ func (s *Server) createBucketByPost(r *http.Request) jsonResponse {
return jsonResponse{errorMessage: err.Error(), status: http.StatusBadRequest}
}

_, err := s.backend.GetBucket(name)
Copy link
Owner

Choose a reason for hiding this comment

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

I was wondering if we should have the backend return an error or something like that (to avoid TOCTOU). This is an emulator though, I imagine TOCTOU isn't really an issue, and if it becomes an issue we can fix it x)

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.

Creating a bucket that already exists should return a 409
2 participants