A focal point is two finite numbers

float.TryParse takes "NaN" and "Infinity", and Math.Clamp keeps a NaN, so `focus=NaN,NaN` on an upload or a media PUT
was stored as given. Once the media was posted, every status and timeline response holding the post, and the Note
and its delivery, failed to serialise, for every viewer. FocalPoint.Parse takes finite numbers only (anything else is
ignored, as an unreadable focus was); the mapper and the renderer leave out a focus that isn't sound, and migration
_016 removes the ones stored before, from the uploads and from the copy each post keeps. What PrivaPub sends is
unchanged for any focus that could be sent before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-10-07 10:23:09 +02:00
1 parent 402f9e0d75
commit 52d201eee9
9 files changed
+100 -17

No files matched your search

@@ -0,0 +1,25 @@
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Entities;
using PrivaPub.Models.Media;
using PostEntity = PrivaPub.Models.Post.Post;
namespace PrivaPub.Infrastructure.Data.Migrations
{
// A focal point of NaN or Infinity (taken as given before FocalPoint) made every status, timeline and Note holding its
// post fail to serialise: it goes, from the upload and from the copy each post keeps.
public class _016_focal_points_are_finite : IMigration
{
public async Task UpgradeAsync()
{
var unsound = new BsonDocument("$in", new BsonArray { double.NaN, double.PositiveInfinity, double.NegativeInfinity });
await DB.Default.Collection<MediaAttachment>().UpdateManyAsync(new BsonDocument("Focus", unsound),
new BsonDocument("$set", new BsonDocument("Focus", BsonNull.Value)));
await DB.Default.Collection<PostEntity>().UpdateManyAsync(new BsonDocument("Media.Focus", unsound),
new BsonDocument("$set", new BsonDocument("Media.$[m].Focus", BsonNull.Value)),
new UpdateOptions { ArrayFilters = [new BsonDocumentArrayFilterDefinition<BsonDocument>(new BsonDocument("m.Focus", unsound))] });
}
}
}