FeedRepository: Embed.Unknown silently dropped during Room serialization #44

Closed
opened 2026-06-22 20:10:27 +00:00 by starsetbyte · 1 comment
Owner

What

FeedViewPost.toEntity() filtered out Embed.Unknown via .takeIf { it !is Embed.Unknown }, so unknown embed types were stored as embedJson = null. On round-trip back to UI, the embed became null — indistinguishable from "no embed at all."

Fix

Removed the .takeIf filter. Unknown embeds now serialize as {} (via TypedUnionSerializer when typeOf() returns null) and deserialize back to Embed.Unknown. The UI still shows nothing for Unknown embeds, but the data is no longer silently discarded.

Updated FeedMappingTest to verify the round-trip behavior.

Fixed in PR #36.

## What `FeedViewPost.toEntity()` filtered out `Embed.Unknown` via `.takeIf { it !is Embed.Unknown }`, so unknown embed types were stored as `embedJson = null`. On round-trip back to UI, the embed became `null` — indistinguishable from "no embed at all." ## Fix Removed the `.takeIf` filter. Unknown embeds now serialize as `{}` (via `TypedUnionSerializer` when `typeOf()` returns null) and deserialize back to `Embed.Unknown`. The UI still shows nothing for Unknown embeds, but the data is no longer silently discarded. Updated `FeedMappingTest` to verify the round-trip behavior. **Fixed in PR #36.**
starsetbyte 2026-06-22 20:10:27 +00:00
Author
Owner

Reverted — the .takeIf { it !is Embed.Unknown } filter is intentional defense. Embed.Unknown exists to prevent unknown lexicon types from crashing a feed page on deserialization, but persisting them as {} adds no value (UI still cannot render them) while creating ambiguity in the DB. Dropping them is correct: on next feed refresh the updated deserializer handles the new type. Closing as wontfix.

Reverted — the `.takeIf { it !is Embed.Unknown }` filter is intentional defense. Embed.Unknown exists to prevent unknown lexicon types from crashing a feed page on deserialization, but persisting them as `{}` adds no value (UI still cannot render them) while creating ambiguity in the DB. Dropping them is correct: on next feed refresh the updated deserializer handles the new type. Closing as wontfix.
Sign in to join this conversation.
No description provided.