Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

MongoDB storage corruption #5

Closed
wafschneider opened this issue Sep 14, 2018 · 2 comments
Closed

MongoDB storage corruption #5

wafschneider opened this issue Sep 14, 2018 · 2 comments
Labels

Comments

@wafschneider
Copy link
Collaborator

wafschneider commented Sep 14, 2018

Saving a record from the profile editor results corruption of the record when using a MongoDB storage backend. Instead of saving the record with the json field intact, the json field is serialized to an array of characters:

{
    "id": "ba393a16-9caf-4833-bfdc-0f7780e6e161",
    "name": "BIBFRAME 2.0 Note",
    "configType": "profile",
    "json": {
        "0": "{",
        "1": "\"",
        "2": "P",
        "3": "r",
        "4": "o",
        "5": "f",
        "6": "i",
        "7": "l",
        "8": "e",
        "9": "\"",
        "10": ":",

This makes MongoDB storage unusable at present, except as read-only.

wafschneider added a commit that referenced this issue Sep 14, 2018
wafschneider added a commit that referenced this issue Sep 14, 2018
@wafschneider
Copy link
Collaborator Author

Updating a record in the profile editor results in a request like this to /verso/api/configs/<recordID>/replace:

{
  "id": "beb3df1d-2e81-4630-8974-ef4a9ed6c6e3",
  "name": "BIBFRAME 2.0 Admin Metadata",
  "configType": "profile",
  "json": "{\"Profile\":{\"resourceTemplates\":[{\"propertyTemplates\":[{\"mandatory\":\"false\",\"repeatable\":\"true\",\"type\":\"literal\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[],\"valueDataType\":{\"remark\":\"http://id.loc.gov/ontologies/bflc/catalogerId\"},\"defaults\":[]},\"propertyURI\":\"http://id.loc.gov/ontologies/bflc/catalogerId\",\"propertyLabel\":\"Your cataloger ID (Windows ID)\"},{\"mandatory\":\"false\",\"repeatable\":\"false\",\"type\":\"literal\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[],\"valueDataType\":{\"dataTypeLabelHint\":\"Date or date and time on which the original metadata first created.\"},\"editable\":\"false\",\"defaults\":[]},\"propertyLabel\":\"Creation date\",\"propertyURI\":\"http://id.loc.gov/ontologies/bibframe/creationDate\"},{\"mandatory\":\"false\",\"repeatable\":\"false\",\"type\":\"literal\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[],\"valueDataType\":{\"dataTypeLabelHint\":\"Date or date and time on which the metadata was modified.\"},\"editable\":\"false\",\"defaults\":[]},\"propertyURI\":\"http://id.loc.gov/ontologies/bibframe/changeDate\",\"propertyLabel\":\"Change date\"},{\"mandatory\":\"false\",\"repeatable\":\"false\",\"type\":\"resource\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[\"http://id.loc.gov/vocabulary/organizations\"],\"valueDataType\":{\"dataTypeURI\":\"http://id.loc.gov/ontologies/bibframe/Agent\"},\"editable\":\"false\",\"repeatable\":\"false\",\"defaults\":[{\"defaultURI\":\"http://id.loc.gov/vocabulary/organizations/dlc\",\"defaultLiteral\":\"DLC\"}]},\"propertyLabel\":\"Assigning agency\",\"remark\":\"\",\"propertyURI\":\"http://id.loc.gov/ontologies/bibframe/source\"},{\"mandatory\":\"false\",\"repeatable\":\"true\",\"type\":\"resource\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[\"http://id.loc.gov/vocabulary/marcauthen\"],\"valueDataType\":{\"dataTypeURI\":\"http://id.loc.gov/ontologies/bibframe/DescriptionAuthentication\"},\"defaults\":[{\"defaultURI\":\"http://id.loc.gov/vocabulary/marcauthen/pcc\",\"defaultLiteral\":\"pcc\"}]},\"propertyLabel\":\"Description authentication\",\"remark\":\"\",\"propertyURI\":\"http://id.loc.gov/ontologies/bibframe/descriptionAuthentication\"},{\"mandatory\":\"false\",\"repeatable\":\"false\",\"type\":\"resource\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[\"http://id.loc.gov/vocabulary/descriptionConventions\"],\"valueDataType\":{\"dataTypeURI\":\"http://id.loc.gov/ontologies/bibframe/DescriptionConventions\"},\"editable\":\"false\",\"repeatable\":\"false\",\"defaults\":[{\"defaultURI\":\"http://id.loc.gov/vocabulary/descriptionConventions/rda\",\"defaultLiteral\":\"rda\"}]},\"propertyLabel\":\"Description conventions\",\"propertyURI\":\"http://id.loc.gov/ontologies/bibframe/descriptionConventions\",\"remark\":\"\"},{\"mandatory\":\"false\",\"repeatable\":\"false\",\"type\":\"resource\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[\"http://id.loc.gov/vocabulary/languages\"],\"valueDataType\":{\"dataTypeURI\":\"http://id.loc.gov/ontologies/bibframe/Language\",\"dataTypeLabel\":\"\"},\"editable\":\"false\",\"repeatable\":\"false\",\"defaults\":[{\"defaultURI\":\"\",\"defaultLiteral\":\"eng\"}]},\"propertyLabel\":\"Description language\",\"remark\":\"\",\"propertyURI\":\"http://id.loc.gov/ontologies/bibframe/descriptionLanguage\"},{\"mandatory\":\"false\",\"repeatable\":\"true\",\"type\":\"literal\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[],\"valueDataType\":{\"dataTypeURI\":\"http://id.loc.gov/ontologies/bibframe/Agent\"},\"editable\":\"false\",\"repeatable\":\"true\",\"defaults\":[{\"defaultURI\":\"http://id.loc.gov/vocabulary/organizations/dlc\",\"defaultLiteral\":\"DLC\"}]},\"propertyLabel\":\"Description modifier\",\"remark\":\"\",\"propertyURI\":\"http://id.loc.gov/ontologies/bibframe/descriptionModifier\"},{\"mandatory\":\"true\",\"repeatable\":\"false\",\"type\":\"resource\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[\"http://id.loc.gov/vocabulary/menclvl\"],\"valueDataType\":{\"dataTypeURI\":\"http://id.loc.gov/ontologies/bflc/EncodingLevel\"},\"defaults\":[]},\"propertyLabel\":\"Encoding level\",\"remark\":\"\",\"propertyURI\":\"http://id.loc.gov/ontologies/bflc/encodingLevel\"},{\"mandatory\":\"false\",\"repeatable\":\"false\",\"type\":\"literal\",\"resourceTemplates\":[],\"valueConstraint\":{\"valueTemplateRefs\":[],\"useValuesFrom\":[],\"valueDataType\":{},\"editable\":\"false\",\"defaults\":[]},\"propertyURI\":\"http://id.loc.gov/ontologies/bflc/profile\",\"propertyLabel\":\"Profile\",\"remark\":\"The profile code for the resource\"}],\"id\":\"profile:bf2:AdminMetadata\",\"resourceURI\":\"http://id.loc.gov/ontologies/bibframe/AdminMetadata\",\"resourceLabel\":\"BIBFRAME 2.0 Admin Metadata\"}],\"id\":\"profile:bf2:AdminMetadata\",\"title\":\"BIBFRAME 2.0 Admin Metadata\",\"description\":\"Metadata for BIBFRAME Resources test\",\"date\":\"2017-05-20\",\"contact\":\"NDMSO\"}}",
  "metadata": {
    "createDate": "2018-09-17T17:25:46.180Z",
    "updateDate": "2018-09-17T18:05:17.223Z",
    "updateUser": null
  }
}

Note that the json field is encoded as a string rather than as an object. If you encode it as an object, it is handled correctly by the storage backend.

@wafschneider
Copy link
Collaborator Author

Closing the issue here, as it is actually a profile editor bug. See lcnetdev/profile-edit#31

kirkhess pushed a commit that referenced this issue Jul 31, 2019
kirkhess pushed a commit that referenced this issue Aug 5, 2019
kefo pushed a commit that referenced this issue Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant