panic after failed unmarshal in GetDeepMutableBody

Description

In 2.8.0, GetDeepMutableBody logs a warning and returns nil if it's passed malformed JSON. If callers aren't checking for this case, subsequent code may panic on a nil Body.

There's been at least one reported case of this, but it's unclear whether the GetDeepMutableBody invocation is the one in documentUpdateFunc or resolveConflict.

Both should be tested with malformed JSON. In the case of documentUpdateFunc, the rev should be rejected, instead of a panic being caught by the recover in blip_sync_context. For conflict resolver, should return as resolveError.

Activity

Show:

CB robot August 3, 2021 at 3:31 PM

Build sync_gateway-3.0.0-318 contains sync_gateway commit 95f7e39 with commit message:
- GetDeepMutableBody returns error on invalid JSON (#5136)

Adam Fraser July 26, 2021 at 6:05 PM

Currently GetDeepMutableBody just returns Body - want to modify that function to return (Body, error), and have callers check for error and fail early.

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Sprint

Fix versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created July 19, 2021 at 9:48 PM
Updated November 1, 2021 at 3:01 PM
Resolved November 1, 2021 at 3:01 PM
Instabug