Project

General

Profile

Actions

Feature #6133

open

Enhance the validation of JSON passed into radosgw-admin calls

Added by Anonymous over 10 years ago. Updated over 10 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
% Done:

0%

Source:
other
Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

At present, any JSON data passed into a radosgw-admin call ('zone set' for example) is only validated in terms of being well-formed JSON. It might be nice to do a little further checking / adjusting, such as removing leading or trailing white space or possibly throwing a warning if the key doesn't match some well-known pattern?

Actions #1

Updated by Alfredo Deza over 10 years ago

Validation of JSON data can be get very complex if we need to do anything more than trimming and very basic assertions as to the type of the information coming in.

The reason behind the complexity in validation is that JSON can be also a very complex data type. I know this very well because I wrote a JSON (or Python Dictionary) validation engine in Python (see: http://notario.cafepais.com/docs/index.html)

And ultimately, that is the type of validation that should be implemented: some engine that can accept complex data structures with a very flexible engine that has great error reporting.

Great error reporting is a must when dealing with these type of data structures. Imagine some deeply nested value that just isn't expected, how can you report correctly where is that value in the tree?

The library I wrote kept track of everything and reported nicely about it.

Take this example data:

{'foo': 
    {
        'a':{'a':10}, 
        'b':{'a':20}, 
        'c':{'a':20}
    }
}

If the validation was expecting a "90" as value for any key in 'foo', this is how that engine would report the actual error:

Invalid: -> foo -> a -> a -> 10  did not match 90

The is the reason why error reporting is important, and also demonstrates how this can easily be very tedious to attempt to validate without a proper engine.

Actions

Also available in: Atom PDF