The Bug That Crashes Your Import Is the Lucky One
This is a submission for DEV's Summer Bug Smash: Clear the Lineup powered by Sentry . You are migrating a 50,000-message Slack workspace to Zulip. Somewhere around message 31,000 the import dies with KeyError: 'ts' . Annoying, but here is the uncomfortable part: that is the lucky outcome. The unlucky one is "ts": "NaN" , where nothing dies, nothing warns, and your company's message history quietly comes out in the wrong order. TL;DR: Zulip's Slack importer used float(message["ts"]) unguarded, both as a sort key and as date_sent . One message with a missing or malformed ts aborted the entire import; a non-finite value like "NaN" did not even raise, it silently broke the sort. My fix ( zulip/zulip#39813 ) skips such messages with a warning and requires ts to parse to a finite float via math.isfinite . The regression test fails with KeyError: 'ts' on the old code. Project Overview Zulip is an open-source team chat server (Django/Python, ~25k stars) with an unusually strict engineering culture: near-total backend test coverage, strict mypy, and a commit discipline of "each commit is a minimal coherent idea". The code I touched lives in zerver/data_import/ : the subsystem that converts exports from Slack, Microsoft Teams, and Mattermost into Zulip's format. This subsystem has one property that should shape every line in it: the input is another tool's output. Import is a long batch process over data of arbitrary quality, and the admin running the migration has no way to "fix" what Slack's export tool produced. A pipeline that dies on record 31,207 of 50,000 is strictly worse than one that skips record 31,207 with a warning. Bug Fix or Performance Improvement get_messages_iterator() in zerver/data_import/slack.py streams every message of the export, sorting each day's messages by timestamp: yield from sorted ( messages_for_one_day , key = get_timestamp_from_message ) where the sort key was simply: def get_timestamp_from_message ( message : ZerverFieldsT ) -> float : retur