• 
      

    Add two new methods for storing JSON extra_data in the API.

    Review Request #9271 — Created Oct. 16, 2017 and submitted

    Information

    Review Board
    release-3.0.x
    8171038...

    Reviewers

    Our extra_data support in the API has previously been limited to
    storing primitive values (strings, booleans, integers) associated with
    top-level keys. It didn't allow for any complex JSON data.

    This change introduces two new methods for storing and managing more
    complex JSON data. Clients can now set the extra_data:json field in
    POST or PUT to a serialized JSON Merge Patch, which is a JSON document
    that will be merged into the root of extra_data. Keys mapped to
    dictionaries in the document will merge the dictionary from the JSON
    Merge Patch. Arrays will replace arrays. Any key set to None will
    remove that key from the dictionary. This is a pretty good,
    straight-forward way of working with JSON data.

    For more advanced usage, clients can set extra_data:json-patch to a
    JSON Patch document, which is a list of operations to perform on
    extra_data. This allows for setting entire JSON structures on
    dictionary keys, at the end of an array, or even at specific array
    indices. Operations can remove parts of the JSON document, copy/move
    data. They can also sanity-check the presence of existing data, aborting
    the entire patch if not present.

    Both forms of patches prevent replacing the entire root resource itself
    (though every key can be specifically deleted), so that clients don't
    accidentally remove all state. They also obey any access restrictions
    imposed by extensions, preventing reading from private parts of a tree
    and writing to private/read-only parts of a tree. Keys with double
    underscores (__keyname) are also still supported, and can occur at any
    level of the tree.

    Documentation on all of this will be added in a future change.

    Unit tests pass.

    Manually tested that both forms of patching work.

    Description From Last Updated

    F821 undefined name 'e'

    reviewbotreviewbot

    Seems like we should return an error in the negative case.

    daviddavid

    Docs here look fine but should probably be pushed as a separate commit.

    daviddavid

    Having an empty PUT seems like we're no longer exercising some code that we used to.

    daviddavid

    Having an empty PUT seems like we're no longer exercising some code that we used to.

    daviddavid
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    chipx86
    david
    1. 
        
    2. reviewboard/webapi/base.py (Diff revision 2)
       
       
       
       
      Show all issues

      Seems like we should return an error in the negative case.

    3. reviewboard/webapi/resources/base_review.py (Diff revision 2)
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      Docs here look fine but should probably be pushed as a separate commit.

      1. Oops, this was meant to be its own commit.

    4. Show all issues

      Having an empty PUT seems like we're no longer exercising some code that we used to.

    5. Show all issues

      Having an empty PUT seems like we're no longer exercising some code that we used to.

    6. 
        
    chipx86
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (b989f23)