MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / validateImportBody

Function validateImportBody

db/validation.go:53–68  ·  view source on GitHub ↗

validateImportBody validates incoming import bodies

(body Body)

Source from the content-addressed store, hash-verified

51
52// validateImportBody validates incoming import bodies
53func validateImportBody(body Body) error {
54 if isPurged, ok := body[BodyPurged].(bool); ok && isPurged {
55 return base.ErrImportCancelledPurged
56 }
57
58 // Prevent disallowed internal properties from being used
59 disallowed := []string{BodyId, BodyRev, BodyExpiry, BodyRevisions}
60 for _, prop := range disallowed {
61 if _, ok := body[prop]; ok {
62 return base.NewHTTPError(http.StatusNotFound, "top-level property '"+prop+"' is a reserved internal property therefore cannot be imported")
63 }
64 }
65 // TODO: Validate attachment data to ensure user is not setting invalid attachments
66
67 return nil
68}
69
70// validateBlipBody validates incoming blip rev bodies
71// Takes a rawBody to avoid an unnecessary call to doc.BodyBytes()

Callers 1

ImportDocRawMethod · 0.85

Calls 1

NewHTTPErrorFunction · 0.92

Tested by

no test coverage detected