Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

fix(settings): say why a held release check has no answer (#8277)

Mike Bradley25103cf4ad19
diff --git a/ods/extensions/services/dashboard-api/models.py b/ods/extensions/services/dashboard-api/models.py
index 88f86696c..128905f42 100644
--- a/ods/extensions/services/dashboard-api/models.py
+++ b/ods/extensions/services/dashboard-api/models.py
@@ -113,6 +113,8 @@ class VersionInfo(BaseModel):
changelog_url: Optional[str] = None
checked_at: Optional[str] = None
check_status: str = "unavailable"
+ # Why GitHub gave no release, while a failed check holds further requests.
+ check_error: Optional[str] = None
class UpdateAction(BaseModel):
diff --git a/ods/extensions/services/dashboard-api/routers/updates.py b/ods/extensions/services/dashboard-api/routers/updates.py
index 9ed53ceb2..41c08a3e1 100644
--- a/ods/extensions/services/dashboard-api/routers/updates.py
+++ b/ods/extensions/services/dashboard-api/routers/updates.py
@@ -307,6 +307,15 @@ def _ensure_release_refresh(force: bool = False) -> Optional[asyncio.Task]:
@router.get("/api/version", response_model=VersionInfo, dependencies=[Depends(verify_api_key)])
async def get_version(force: bool = False):
"""Get current ODS version without blocking page load on GitHub."""
+ result = await _version_result(force)
+ # While a failed check holds requests, say why there is no confirmed
+ # release: "try again" would be wrong for up to an hour.
+ if result["check_status"] in ("unavailable", "stale") and _release_checks_held(force=False):
+ result["check_error"] = _held_check_error()
+ return result
+
+
+async def _version_result(force: bool) -> dict:
current = await asyncio.to_thread(_read_current_version)
if await asyncio.to_thread(_update_check_disabled):
return _build_version_result(current, None, "disabled")
diff --git a/ods/extensions/services/dashboard-api/tests/test_update_detection.py b/ods/extensions/services/dashboard-api/tests/test_update_detection.py
index 2ef86492f..efb67817c 100644
--- a/ods/extensions/services/dashboard-api/tests/test_update_detection.py
+++ b/ods/extensions/services/dashboard-api/tests/test_update_detection.py
@@ -222,3 +222,21 @@ def test_dry_run_shares_the_dashboard_cache_and_rate_limit_hold(test_client, mon
assert get.await_count == 0
assert data['latest_version'] is None
assert data['version_check_error'] == "GitHub's request limit for this network is used up; try again in 10 min"
+
+
+def test_a_held_check_says_why_it_has_no_release(test_client, monkeypatch):
+ # Settings told the owner to "try again", which the hold refuses for up to an hour.
+ monkeypatch.setattr(updates, '_read_current_version', lambda: '3.0.0')
+ reset = str(int(time.time()) + 600)
+ _github(monkeypatch, _response(403, {'x-ratelimit-remaining': '0', 'x-ratelimit-reset': reset}))
+
+ data = test_client.get('/api/version?force=true', headers=test_client.auth_headers).json()
+
+ assert data['check_status'] == 'unavailable'
+ assert data['check_error'] == "GitHub's request limit for this network is used up; try again in 10 min"
+
+ monkeypatch.setattr(updates, '_version_hold', {'until': 0.0, 'rate_limited': False})
+ _github(monkeypatch, _response(200, data={'tag_name': 'v3.0.0', 'html_url': 'https://github.com/x'}))
+ data = test_client.get('/api/version?force=true', headers=test_client.auth_headers).json()
+ assert data['check_status'] == 'checked'
+ assert data['check_error'] is None
diff --git a/ods/extensions/services/dashboard/src/pages/Settings.jsx b/ods/extensions/services/dashboard/src/pages/Settings.jsx
index ac27d001e..c17e429cc 100644
--- a/ods/extensions/services/dashboard/src/pages/Settings.jsx
+++ b/ods/extensions/services/dashboard/src/pages/Settings.jsx
@@ -223,7 +223,8 @@ export default function Settings({ activeSection = 'all' }) {
if (announce) {
setNotice({
type: !checked || versionData.update_available ? 'warn' : 'info',
- text: !checked ? 'Could not confirm the latest release. Try checking again.' : versionData.update_available && versionData.latest ? `Update available: v${versionData.latest}` : 'You are on the latest available release or a newer development version.',
+ // A held check says why, e.g. a used-up GitHub request limit that "try again" cannot fix.
+ text: !checked ? (versionData.check_error ? `${versionData.check_error}.` : 'Could not confirm the latest release. Try checking again.') : versionData.update_available && versionData.latest ? `Update available: v${versionData.latest}` : 'You are on the latest available release or a newer development version.',
})
window.dispatchEvent(new Event('ods-version-checked'))
}
diff --git a/ods/extensions/services/dashboard/src/pages/Settings.test.jsx b/ods/extensions/services/dashboard/src/pages/Settings.test.jsx
index 78ffb61e2..d86a3c2e6 100644
--- a/ods/extensions/services/dashboard/src/pages/Settings.test.jsx
+++ b/ods/extensions/services/dashboard/src/pages/Settings.test.jsx
@@ -129,6 +129,16 @@ describe('Settings', () => {
expect(await screen.findByText('Could not confirm the latest release. Try checking again.')).toBeVisible()
expect(screen.queryByText('Current release')).toBeNull()
})
+
+ it('says why a held release check has no answer instead of asking to try again', async () => {
+ // Workstation06 (2026-10-27): the site's address had used up GitHub's unauthenticated requests.
+ const reason = "GitHub's request limit for this network is used up; try again in 12 min"
+ renderSettings(url => String(url).startsWith('/api/version') ? response({ current:'3.0.0', latest:null, update_available:false, check_status:'unavailable', checked_at:null, check_error:reason }) : null)
+ expect(await screen.findByText('Update check unavailable')).toBeVisible()
+ fireEvent.click(screen.getByRole('button', {name:'Check', exact:true}))
+ expect(await screen.findByText(`${reason}.`)).toBeVisible()
+ expect(screen.queryByText('Could not confirm the latest release. Try checking again.')).toBeNull()
+ })
it('does not invent uptime or a live state when uptime is missing', async () => {
renderSettings(url => url === '/api/settings/summary' ? response({...summary,uptime:undefined}) : null)
const label = await screen.findByText('Uptime')