Closed mhl closed 8 years ago
If you just reorder items in an 3 item array, then the JSON patch that is generated might be something like the following:
======= op: add path: /other_names/0 value: {u'note': u'', u'name': u'Joey', u'end_date': u'', u'start_date': u''} ======= op: remove path: /other_names/3
The idea is that these operations are applied in order; first the new item is inserted at the start, then the fourth item, at index 3, is removed.
However, the JSON patch isn't used like that in candidates/diffs.py - it tries to look up other_names/3 in the original data, which gives this error:
candidates/diffs.py
other_names/3
JsonPointerException: index '3' is out of bounds
Instead, it should apply the earlier operations before trying to parse the later ones.
This error is causing some person pages to error.
There's a failing test for this in the 873-broken-jsonpatch-parsing branch (PR here: https://github.com/mysociety/yournextrepresentative/pull/874)
If you just reorder items in an 3 item array, then the JSON patch that is generated might be something like the following:
The idea is that these operations are applied in order; first the new item is inserted at the start, then the fourth item, at index 3, is removed.
However, the JSON patch isn't used like that in
candidates/diffs.py
- it tries to look upother_names/3
in the original data, which gives this error:Instead, it should apply the earlier operations before trying to parse the later ones.
This error is causing some person pages to error.