centraldogma icon indicating copy to clipboard operation
centraldogma copied to clipboard

Fix a bug where JSON content is not always validated

Open ikhoon opened this issue 1 year ago • 3 comments

Motivation:

If an invalid JSON content is submitted to Central Dogma Server using REST API, the JSON is not validated and it is saved as is.

The file content is formatted as a text so node.get("content") returns TextNode and it is regarded as a string although it is a JSON object. https://github.com/line/centraldogma/blob/9030505a928006d32f3897dc08823dac0d5fd6c2/server/src/main/java/com/linecorp/centraldogma/server/internal/api/converter/ChangesRequestConverter.java#L91-L95

Modifications:

  • Pass a raw text value to Change.ofJsonUpsert() and make the JSON validated.

Result:

Central Dogma server now correctly rejects an invalid JSON content.

ikhoon avatar Feb 14 '23 11:02 ikhoon