Skip to content

[v0.8.3] Offline-registry check fix#54

Merged
LittleCoinCoin merged 3 commits into
CrackingShells:mainfrom
LittleCoinCoin:hotfix/offline-registry
May 31, 2026
Merged

[v0.8.3] Offline-registry check fix#54
LittleCoinCoin merged 3 commits into
CrackingShells:mainfrom
LittleCoinCoin:hotfix/offline-registry

Conversation

@LittleCoinCoin
Copy link
Copy Markdown
Member

Summary

  • Read-only commands (e.g. hatch mcp list servers) now keep working when the registry is unreachable and no usable cache exists, instead of crashing with a traceback
  • RegistryRetriever.get_registry() returns a REGISTRY_UNAVAILABLE sentinel when offline with no cache, rather than raising
  • Remote installs now fail with a clear "registry is unavailable" message instead of an opaque error; local-package installs are unaffected
  • Adds 2 offline regression tests covering the no-cache and stale-cache paths (7/7 offline regression tests pass)

Bug Fixes

Registry retrieval crashed when offline with no cache (hatch/registry_retriever.py)

Root cause: When the remote registry could not be fetched and no local cache file existed, get_registry() propagated the fetch exception. Every command that touches the registry on startup — including purely read-only ones — failed with a traceback the moment the machine was offline.

Example: hatch mcp list servers on a laptop with no network and a cold cache → unhandled exception instead of an (empty) listing.

Solution:

  • Introduced a module-level REGISTRY_UNAVAILABLE sentinel ({"status": "unavailable", "repositories": []}).
  • Wrapped the remote fetch so that on failure it falls back to the cached registry when one exists (logging a "may be stale" warning), and only returns the sentinel when there is no cache at all.
  • The sentinel return path is an early return that bypasses _write_local_cache, the in-memory cache update, and _save_last_fetch_time, so the placeholder is never persisted to disk.
  • Downgraded the "registry not found for today/yesterday" log from error to warning, with a message that names offline/unpublished-release as the likely cause.

Test coverage:

  • test_offline_no_cache_returns_unavailable_sentinel — offline with no cache returns the sentinel and asserts the cache file is never written.
  • test_offline_stale_cache_returns_stale_data_not_sentinel — offline with a stale cache returns the real (stale) data, not the sentinel.

Remote install raised an opaque error against an unavailable registry (hatch/installers/dependency_installation_orchestrator.py)

Root cause: With the registry now able to be unavailable, the remote-install path would proceed to query a registry with no repositories and surface a confusing failure.

Solution:

  • Guard the remote-package branch: when registry_data.get("status") == "unavailable", raise a DependencyInstallationError with an actionable message — "registry is unavailable. Connect to the internet and retry, or use a local package path."
  • Local-package installs do not consult the registry and are therefore unaffected.

Developer Experience

Offline regression coverage

The two new tests in tests/test_registry_retriever.py lock in the offline contract: the sentinel is returned (never persisted) when there is no cache, and a stale cache is preferred over the sentinel. Combined with the existing offline checks, 7/7 offline regression tests pass.

LittleCoinCoin and others added 3 commits May 31, 2026 20:33
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@LittleCoinCoin LittleCoinCoin merged commit c641597 into CrackingShells:main May 31, 2026
1 check passed
cracking-shells-semantic-release Bot pushed a commit that referenced this pull request May 31, 2026
## <small>0.8.3 (2026-05-31)</small>

* Merge pull request #54 from LittleCoinCoin/hotfix/offline-registry ([c641597](c641597)), closes [#54](#54)
* fix(installer): guard remote install against unavailable registry ([49a1c4f](49a1c4f))
* fix(registry): return REGISTRY_UNAVAILABLE sentinel when offline ([180c77d](180c77d))
* test(registry): add offline no-cache and stale-cache regression tests ([e787108](e787108))
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