fix(saves): re-register the device when RomM no longer has its id#1573
Open
danielcopper wants to merge 1 commit into
Open
fix(saves): re-register the device when RomM no longer has its id#1573danielcopper wants to merge 1 commit into
danielcopper wants to merge 1 commit into
Conversation
When RomM's database is wiped or restored, the device id the plugin cached no longer exists server-side, so every device-scoped save call 404s. The best-effort update_device touch in ensure_device_registered already makes that 404 the natural, zero-extra-request healing point, but it swallowed the error and trusted the dead id forever. Peel a definitive RommNotFoundError off that touch: on a 404, forget the dead id (clearing the kv_config row) and fall through to the existing registration path so a fresh id is minted and persisted. Every other touch failure stays swallowed best-effort — a transport blip must not throw away a valid id and churn a re-registration. If the re-registration itself fails mid-heal, the method returns the classified failure with an empty id and the dead id left cleared, a clean state the next call retries. Healing fires on every plugin load, so the fix applies itself the moment the release is installed — no user action required. Closes #1560.
|
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.



What this is
PR 2 of #1570. When RomM's database is wiped or restored, the device id the plugin cached no longer
exists on the server. Every device-scoped save call then gets a definitive 404, and the plugin was stuck
reporting the server as offline forever. PR 1 made that message honest (
not_found); this PR makes itrecover:
ensure_device_registerednow detects that its cached device id is dead and re-registers afresh one instead of trusting the stale id blindly.
Closes #1560.
The verified facts this rests on
"Device with ID <uuid> not found"), surfaced asRommNotFoundError. A dead ROM id does not 404 the saves endpoint — it returns200 []. So a device-scoped 404 is unambiguously a dead device, never a dead ROM.ensure_device_registeredalready callsupdate_device(cached_id)as a best-effort touch on every runand swallowed any exception there. That swallowed call is exactly where a dead cached id produces
its 404 — the natural healing point, at zero extra requests.
src/index.tsx, when save-sync is enabled) and before everysave-sync. So installing the release — which reloads the plugin — applies the fix on its own. No manual
step for the user.
The change
ensure_device_registered(py_modules/services/saves/sync_engine/devices.py): the best-effortupdate_devicetouch now peels a definitiveRommNotFoundErrorintoforget_device()+ fall-through tothe existing registration path, minting and persisting a fresh id and returning it (not the stale one).
The discipline that matters: only a
RommNotFoundErrorheals. Every other exception — transport,timeout, 403, generic — stays a best-effort swallow that keeps the cached id, so a server blip can never
throw away a valid registration and churn a re-register. The
except RommNotFoundErroris ordered beforethe broad clause, and the broad clause binds no verdict slug, so the
check_404_not_unreachablegate(from PR 1) stays green. A re-register that itself fails after a forget returns a clean
{success: false, reason, message}with the id left cleared — a retriable state, no half-state.Scope is one service method, its tests, and one docs note. The read callables (already honest via PR 1),
forget_device/register_device, the origin-change trigger, and the frontend are untouched.Docs
docs/user-guide/troubleshooting.md— a device the server no longer has is re-registered automatically onthe next plugin load; the deleted/re-added-ROM re-check (a new rom_id — separate work) stays described as
the user's action.
Verification
mise run gategreen: 6300 backend + 2238 frontend tests, ruff/basedpyright clean,check_404_not_unreachableOK, 31/31 intest_devices.py. Every test asserts persisted kv_config state(id changed on heal / kept on a transport failure / cleared on a failed re-register), not call counts.
On-device (backend path, can't be unit-tested): stage a device id the server no longer has (register,
then remove it server-side), load the plugin or launch a game, and confirm a fresh device appears in
RomM's device list with no offline claim; a genuine transient outage during the touch must NOT
re-register.
Closes part of #1570.