fix(worker): graceful skip when Servers or Messages data is absent#83
Merged
Androz2091 merged 1 commit intomainfrom May 7, 2026
Merged
fix(worker): graceful skip when Servers or Messages data is absent#83Androz2091 merged 1 commit intomainfrom
Androz2091 merged 1 commit intomainfrom
Conversation
A user reported UNKNOWN_ERROR for package 4aa23a2a6ea2f52ba9016a723143b792.
Traceback:
File "/app/tasks.py", line 466, in read_analytics_file
server_content = zip.open(server_path)
KeyError: "There is no item named 'Servers/index.json' in the archive"
Same fallback bug that PR #82 fixed for the analytics path: when the
discovered root is None, the old code blindly assigned the canonical
literal 'Servers/index.json' (resp. 'Messages/index.json') and let
zip.open KeyError if that file isn't actually in the archive. That
happens when the user un-ticks 'Servers' (or 'Messages') in Discord's
data-request form.
Fix: only assign a path that actually exists in zip.namelist(); if
nothing matches, set it to None and skip the read block, marking
is_partial=True. The rest of the worker copes with empty servers /
empty channels lists (the message-CSV walker filters by
namelist anyway, so it just processes 0 channels).
After this:
- No Servers folder → no guild-scoped stats but DMs/friends/payments OK
- No Messages folder → no channel-scoped stats but server list/payments OK
- Both missing → minimal package, but no crash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same fallback bug that PR #82 fixed for the analytics path, but for Servers and Messages.
A user reported UNKNOWN_ERROR for package `4aa23a2a6ea2f52ba9016a723143b792`. CloudWatch:
```
File "/app/tasks.py", line 466, in read_analytics_file
server_content = zip.open(server_path)
KeyError: "There is no item named 'Servers/index.json' in the archive"
```
The user un-ticked Servers in Discord's data-request form. The old code:
```py
servers_root = find_servers_root(namelist)
if not servers_root:
server_path = 'Servers/index.json' # blind fallback
if server_path not in namelist and 'servers/index.json' in namelist:
server_path = 'servers/index.json'
else:
server_path = f'{servers_root}/index.json'
server_content = zip.open(server_path) # KeyError if neither exists
```
If `find_servers_root` returns None and neither lowercase fallback matches the existence check (the existing logic only swaps to lowercase if the canonical path isn't present and lowercase is — so if both are absent, `server_path` ends up as the literal `'Servers/index.json'`), `zip.open` blows up.
Same exact pattern in the Messages block right below.
Fix
Make the path resolution defensive — only assign a path that actually exists in `zip.namelist()`; if nothing matches, set None and skip the read block, marking `is_partial=True`. The rest of the worker tolerates empty servers / empty channels lists (the message-CSV walker filters by namelist, so it processes 0 channels naturally).
Possible outcomes after this:
Test plan