Merge pull request #1980 from molecula/fb-1260-err-field-exists

return correct ErrFieldExists so we give an HTTP 409
This commit is contained in:
Matthew Jaffee 2022-03-15 23:33:26 -05:00 • committed by GitHub
commit 7ff1d94648
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -669,7 +669,9 @@ func (i *Index) persistField(ctx context.Context, cfm *CreateFieldMessage) error
if b, err := i.serializer.Marshal(cfm); err != nil {
return errors.Wrap(err, "marshaling")
} else if err := i.Schemator.CreateField(ctx, cfm.Index, cfm.Field, b); err != nil {
} else if err := i.Schemator.CreateField(ctx, cfm.Index, cfm.Field, b); errors.Cause(err) == disco.ErrFieldExists {
return ErrFieldExists
} else if err != nil {
return errors.Wrapf(err, "writing field to disco: %s/%s", cfm.Index, cfm.Field)
}
return nil