Skip to content

feat(worker): MISSING_USER_DATA error when user.json is absent#80

Merged
Androz2091 merged 1 commit intomainfrom
feat/missing-user-data-error
May 2, 2026
Merged

feat(worker): MISSING_USER_DATA error when user.json is absent#80
Androz2091 merged 1 commit intomainfrom
feat/missing-user-data-error

Conversation

@Androz2091
Copy link
Copy Markdown
Member

Summary

Two production packages today hit `UNKNOWN_ERROR` four times each before the user gave up retrying:

```
KeyError: "There is no item named 'Account/user.json' in the archive"
File "/app/tasks.py", line 220, in read_analytics_file
user_content = zip.open(user_path)
```

Root cause: Discord's export request form has a checkbox called User data. If the user un-ticks it, the export package ships without `Account/user.json` (or the localized equivalent). Our worker needs `user.json` for the package owner's identity (id, username, discriminator, avatar) — without it there's nothing meaningful to compute, so we should fail fast with a clear message rather than crash on a missing-key.

What changed

  • `read_analytics_file` now uses an explicit elif chain to find `user.json`. When `find_user_root()` and both legacy fallbacks (`Account/user.json`, `account/user.json`) all come up empty, raise `MISSING_USER_DATA` instead of falling through to a guaranteed KeyError.
  • `MISSING_USER_DATA` added to the `EXPECTED_ERROR_CODES` tuple in `process_package` so it surfaces verbatim through the status endpoint instead of being relabeled `UNKNOWN_ERROR`.

No behavior change for packages that do have `user.json` — the code path resolves to the same `user_path` value.

Frontend follow-up (separate PR)

The status response type in dumpus-app needs `MISSING_USER_DATA` added to the `errorMessageCode` union, plus a friendly copy string along the lines of:

Your Discord export didn't include your User data. When you request your data again, make sure the User data checkbox is ticked.

Happy to open that PR right after this merges.

Test plan

  • Merge → CI deploys.
  • No regression on packages that contain `user.json` (resolves to same code path).
  • Submit a package without `user.json` (or wait for one of the affected users to retry) and verify the status endpoint returns `isErrored: true, errorMessageCode: 'MISSING_USER_DATA'`.

Discord exports drop user.json (and the entire Account folder) when
the user un-ticks the 'User data' checkbox in the request form. We
need user.json to anchor the rest of the analysis on the package
owner's identity, so a package without it has nothing useful to
compute.

The old code path landed on a KeyError("There is no item named
'Account/user.json' in the archive") and got relabeled UNKNOWN_ERROR
in process_package — multiple users in production hit this and
retried 4+ times before giving up.

Now: when neither find_user_root() nor either legacy fallback locates
a user.json entry, raise MISSING_USER_DATA. The error code is added
to EXPECTED_ERROR_CODES so it surfaces verbatim through the API
status endpoint instead of being squashed.

Frontend follow-up (separate PR): add MISSING_USER_DATA to the status
response type and copy a friendly message asking the user to
re-export with the User data option enabled.
@Androz2091 Androz2091 merged commit 19af40d into main May 2, 2026
1 check passed
@Androz2091 Androz2091 deleted the feat/missing-user-data-error branch May 2, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant