Skip to content

Instantly share code, notes, and snippets.

@mxstrand
Created February 25, 2026 22:49
Show Gist options
  • Select an option

  • Save mxstrand/7d2fcbe503a7ed2e9026b0698fa7e98c to your computer and use it in GitHub Desktop.

Select an option

Save mxstrand/7d2fcbe503a7ed2e9026b0698fa7e98c to your computer and use it in GitHub Desktop.
Fix: topic creator dropped from member list for pre-July-2024 topics (cyans-web ExportToNebulaCommand)

Bug: Topic creator dropped from participant list during export/import

Problem

Topics created before July 2024 don't have createdBy or createdAt stored in the Evolver state. In ExportToNebulaCommand::extractMembersFromEvents(), the creator is only added to the members list when $createdBy is truthy:

$createdBy = $topicState['createdBy'] ?? null;  // null for pre-July-2024 topics

// Add creator as owner (always active)
if ($createdBy) {                                // ← skipped when null
    $membersList[$createdBy] = [ ... ];
}

Since the topic creator was never explicitly added via a topic:add-user event (they were implicitly a member by creating the topic), they are completely absent from the exported _members.yaml. Nebula's topic:import only creates TopicMember records from that file — so the creator is lost.

Fix

In extractMembersFromEvents(), add a fallback that recovers the creator from the topic:create raw event when topicState['createdBy'] is null.

Before (line 345–347):

$membersList = [];
$createdBy = $topicState['createdBy'] ?? null;
$createdAt = $topicState['createdAt'] ?? null;

After:

$membersList = [];
$createdBy = $topicState['createdBy'] ?? null;
$createdAt = $topicState['createdAt'] ?? null;

// Fallback: extract creator from topic:create event for pre-July-2024 topics
if (!$createdBy) {
    foreach ($rawEvents as $rawEvent) {
        if (($rawEvent['type'] ?? '') === 'topic:create') {
            $createdBy = $rawEvent['payload']['user'] ?? $rawEvent['meta']['createdBy'] ?? null;
            if (!$createdAt) {
                $createdAt = $rawEvent['meta']['createdAt'] ?? null;
            }
            break;
        }
    }
}

This also recovers createdAt from the same event, which fixes the related issue where pre-July-2024 topics show today's date as their creation date.

Additional consideration

extractTopicMetadata() has the same gap — created_by_username and created_at fall back to null/$now respectively. The same topic:create event fallback could be applied there.

How to verify

  1. Run export with --validate on a pre-July-2024 topic
  2. Check the _members.yaml — creator should now be listed
  3. Check the _topic.yamlcreated_at and created_by_username should be populated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment