mysociety / popit

DEPRECATED - Development on PopIt has stopped and it is no longer being maintained
https://goo.gl/Vvej4Q
Other
76 stars 33 forks source link

there's no safe way currently to PUT an update to images in the images array #794

Closed mhl closed 9 years ago

mhl commented 9 years ago

The _id field in each image in images is currently broken (see https://github.com/mysociety/popit/issues/470) in that one can't PUT back a version of the images array that contains those "_bsontype": "ObjectID' IDs - I found that you'll get a "Argument passed in must be a single String of 12 bytes or a string of 24 hex characters" error. I understand from what @chrismytton said that even if you PUT an _id with the 24 hex character ID, this still wouldn't work currently. If you don't include the _id then the images array will be updated, but the ID will be lost which creates problems for PopIt hosted images. (@chrismytton did a workaround so now such images don't 404, but other things are still broken, e.g. deleting such images by ID). This basically means that there's currently no way to safely PUT an update to images.

In user story terms: as a developer, I want to be able to PUT updates to the images array so that I can correct image metadata and reorder the images.

chrismytton commented 9 years ago

Looking at the code it seems that it will deal with casting the images _id fields to a MongoDB ObjectId. So the actual issue here seems to be https://github.com/mysociety/popit/issues/470, which is causing problems when PUTing the images array back again.