sync(...) does not propagate server/token errors
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 5
- Forks
- 8
- Avg merge
- 12d 16h
- Merged PRs (30d)
- 4
Description
While implementing the config migration from v1 to v2 in the desktop app, I noticed that sync() would not surface the invalid token error returned from the server.
Consider the following case:
- The app's token has become invalid
- The app attempts to perform a soft sync e.g.:
syncManager.sync(force) // force == false
- The reported failure will be:
org.json.JSONException: JSONObject["count"] not found.
at org.json.JSONObject.get(JSONObject.java:596)
at org.json.JSONObject.getInt(JSONObject.java:768)
at eu.pretix.libpretixsync.sync.BaseDownloadSyncAdapter.downloadData(BaseDownloadSyncAdapter.kt:205)
at eu.pretix.libpretixsync.sync.BaseDownloadSyncAdapter.download(BaseDownloadSyncAdapter.kt:56)
at eu.pretix.libpretixsync.sync.AllSubEventsSyncAdapter.download(AllSubEventsSyncAdapter.kt:125)
at eu.pretix.libpretixsync.sync.SyncManager.download(SyncManager.java:333)
at eu.pretix.libpretixsync.sync.SyncManager.downloadData(SyncManager.java:392)
at eu.pretix.libpretixsync.sync.SyncManager.sync(SyncManager.java:181)
The first method to encounter the server error in this callstack is fetchDeviceInfo() which receives the following vdata response:
{"detail":"Invalid token."}
but throws a org.json.JSONException: JSONObject["server"] not found. error because of the following:
configStore.setKnownPretixVersion(vdata.getJSONObject("server").getJSONObject("version").getLong("pretix_numeric"));:
This is just printed and it won't be until a later JSON error during the downloadData() method that an uncaught JSON error surfaces back the caller.
This is not blocking, and I imagine it happens only if the device access is somehow revoked from the pretix but it will be nice to have way to show the actual reason instead of the JSON error.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in SyncManager.java at fetchDeviceInfo() and follow the invalid-token response through configStore.setKnownPretixVersion; then inspect BaseDownloadSyncAdapter.kt and the downloadData() path. Reproduce a soft sync with the shown {"detail":"Invalid token."} response and ensure the caller receives the server/token failure rather than a later JSON exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100