Repository navigation
Description
What happened
An explicit codex-unlock check-update fails with exit 3 and update check failed: cache_directory_unavailable when the cache directory cannot be created or written, without contacting the registry at all.
refreshUpdateCache acquires the refresh lease, which requires a private cache directory, before fetching. An unavailable lease returns an error immediately. A successful fetch followed by a failed cache write is also reported as an error.
Reproduction: XDG_CACHE_HOME=<dir with mode 0500> codex-unlock check-update --json → exit 3. With a writable cache location it returns status: ok, exit 0.
What you expected
docs/update-security.md defines the cache as advisory. A user-requested network check should succeed when the registry is reachable, even if the result cannot be cached (for example on a read-only home, a sandbox, or a filesystem that cannot represent mode 0700). A cache write failure should at most be reported as a warning.
Environment
codex-unlock0.4.0 at6227e6c- macOS 27.0 arm64, Node.js 22.14.0
Source evidence
- Lease required before fetch; write failure becomes error:
Lines 662 to 687 in 6227e6c
export async function refreshUpdateCache( options: RefreshUpdateCacheOptions = {}, ): Promise<RefreshUpdateCacheResult> { const location = options.location ?? updateCacheLocation(); const leaseAttempt = acquireUpdateRefreshLease(location); if (leaseAttempt.status === "contended") { return { status: "skipped", reason: "refresh_in_progress" }; } if (leaseAttempt.status === "unavailable") { return { status: "error", reason: leaseAttempt.reason }; } try { const fetched = await fetchNpmLatest(options); if (fetched.status === "error") return fetched; const written = writeUpdateCache( fetched.record.latest, location, Date.parse(fetched.record.checkedAt), ); return written.status === "written" ? { status: "updated", record: written.record } : written; } finally { leaseAttempt.lease.release(); } } - CLI converts it to exit 3:
Lines 264 to 278 in 6227e6c
async function checkUpdate(json: boolean): Promise<number> { const refreshed = await refreshUpdateCache(); const observation = refreshed.status === "updated" ? { status: "fresh" as const, record: refreshed.record } : refreshed.status === "skipped" ? readUpdateCache() : null; if (observation?.status !== "fresh") { const reason = refreshed.status === "error" ? refreshed.reason : refreshed.status === "skipped" ? "refresh_in_progress" : "update_check_failed"; throw new Error(`update check failed: ${reason}`); }
Acceptance criteria
check-updatefetches and reports the latest version when the lease or cache write is unavailable (lease contention may still skip).- Cache unavailability does not change the exit code or JSON
statusof an otherwise successful check. - A test covers an unwritable cache directory.
Scope and limitations
- Functional reliability only; automatic advisory notices are unaffected by design.
Checked
- security: specify update-cache privacy and failure isolation #28 / fix: harden update metadata boundary #38 / feat: add cached update notices #40 covered cache privacy and isolation, not this path.
Activity
fix: harden update cache boundary