feat(fio): check fio credentials on save and show the fio connection status - #68
Merged
Merged
Conversation
…status - Profile save verifies changed FIO credentials via FIO /auth: 400 with codes fio_required, fio_invalid_key, fio_username_mismatch; FIO down still saves; profile_update throttle 10/min - Profile gains fio_status and fio_last_refreshed_at, derived from the new GameFIOPlayerData.fio_status_code (200 data, 204 no data, 401 rejected) - Refresh task: 401 fails the row at once, 204 is "no data yet", not an error - Migration 0024 adds the field, 0025 backfills existing rows (RunPython) - Admin: "FIO answer" column, filter and header fact; user page shows the status the user sees Spec: specs/2026-10-01-fio-credential-check.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 32 |
| Duplication | 0 |
🟢 Coverage 98.98% diff coverage · +0.11% coverage variation
Metric Results Coverage variation ✅ +0.11% coverage variation (-1.00%) Diff coverage ✅ 98.98% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (bcee4cc) 4646 4435 95.46% Head commit (41d1632) 4735 (+89) 4525 (+90) 95.56% (+0.11%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#68) 98 97 98.98% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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 and why
The profile accepted any FIO API key and PrUn username. A wrong key or a typo failed silently in the Celery refresh (19 users, 670
fio_refresh_failed401s in 14 days) and kept retrying. Saving FIO credentials now checks them against FIO right away, and the profile reports the real FIO state (none, syncing, ok, no data, key rejected, error).Changes
PATCH /user/profile/verifies changed FIO credentials via FIO/auth(3 s). Errors are 400 field errors whose message is a stable code:fio_required,fio_invalid_key,fio_username_mismatch; the key owner's name is never returned. Clearing both disconnects without a call; FIO down or timing out still saves and logsfio_verify_unavailable.profile_update(10/min), on the update action only.fio_statusandfio_last_refreshed_at(additive), derived from the newGameFIOPlayerData.fio_status_code(200 data, 204 no data yet, 401 key rejected).RunPythondata migration (an exception to "migrations generated only", same pattern asgamedata/0005,0023): rows without errors → 200, rows that last failed with a 401 → 401. Tested intests/gamedata/migrations/.fio_verify_completed(result); the Axiom builder in the workspace repo has a matching panel.How it was verified
QA PASS after three rounds (code review against the 11 acceptance criteria, full e2e walk in the running app with a real FIO account: wrong key, mismatch, missing field, valid pair Syncing → Active, rejected key, no data, admin pages).
uv run ruff check,ruff format --check,ty check,pytestall pass.Deploy order
Deploy backend first; it is backward compatible (new fields only; the current frontend already sends both FIO fields together). Paired frontend PR: PRUNplanner/frontend#542
🤖 Generated with Claude Code