Tyrrrz/DiscordChatExporter · error · InvalidOperationException

Failed to locate the channel index inside the data package.

Error message

Failed to locate the channel index inside the data package.

What it means

Thrown as InvalidOperationException by DataDump.ParseAsync when the opened ZIP archive contains no entry whose full name equals 'messages/index.json' (case-insensitive). The index is the entry point for parsing a Discord data package, so without it the dump cannot be interpreted. This is a data-integrity error, not a Discord API error.

Source

Thrown at DiscordChatExporter.Core/Discord/Dump/DataDump.cs:52

        }

        return new DataDump(channels);
    }

    public static async ValueTask<DataDump> LoadAsync(
        string zipFilePath,
        CancellationToken cancellationToken = default
    )
    {
        await using var archive = await ZipFile.OpenReadAsync(zipFilePath, cancellationToken);

        // Use case-insensitive search to accommodate for different data dump versions
        // https://github.com/Tyrrrz/DiscordChatExporter/issues/1459
        var entry =
            archive.Entries.FirstOrDefault(e =>
                e.FullName.Equals("messages/index.json", StringComparison.OrdinalIgnoreCase)
            )
            ?? throw new InvalidOperationException(
                "Failed to locate the channel index inside the data package."
            );

        await using var stream = await entry.OpenAsync(cancellationToken);
        using var document = await JsonDocument.ParseAsync(stream, default, cancellationToken);

        return Parse(document.RootElement);
    }
}

View on GitHub (pinned to f6865c8216)

Solutions

  1. Re-download the complete data package from Discord (User Settings > Privacy & Safety > Request Data) and wait for it to finish.
  2. Unzip and confirm `messages/index.json` exists at the archive root; re-zip preserving the directory structure if you repackaged it.
  3. Point the command at the original, unmodified package zip.
Defensive patterns

Strategy: validation

Validate before calling

using var archive = await ZipFile.OpenReadAsync(zipPath, ct);
if (!archive.Entries.Any(e => e.FullName.Equals("messages/index.json", StringComparison.OrdinalIgnoreCase)))
    throw new ArgumentException("ZIP is not a Discord data package (missing messages/index.json).");

Try / catch

try { await DataDump.ParseAsync(zipPath, ct); }
catch (InvalidOperationException ex) when (ex.Message.Contains("channel index"))
{
    logger.LogError("'{Path}' is not a valid Discord data package — re-request it from Discord.", zipPath);
}

Prevention

When it happens

Trigger: Calling DataDump.ParseAsync with a zipFilePath that is a valid ZIP but is not a Discord data package (or is a different/incomplete version). The FirstOrDefault at DataDump.cs:48 returns null and the `??` throws.

Common situations: Pointing --dump at an arbitrary zip, a partial download, or a re-zipped folder that lost the original layout; an older/newer data package version that renamed the index; the user exported only the account section instead of the full package request.

Related errors


AI-assisted analysis of Tyrrrz/DiscordChatExporter@f6865c8216 (2026-08-13). Data as JSON: /api/errors/42a221bdc7d198ff. Report an issue: GitHub.