fix: skip update check (not just cache write) when config dir is absent (Bugbot #397) - #414
Merged
Merged
Conversation
…nt (Bugbot #397) #404 made writeUpdateCache refuse to recreate a wiped ~/.tracebloc, but latestReleaseVersion still fetched from GitHub whenever the cache couldn't be read. On a fresh install / after offboard the dir is absent, so the throttle can never be persisted and every TTY command re-hit the releases API, burning updateCheckTimeout each time. Reconcile both: introduce configDirExists as the single "can the throttle be persisted?" gate, used by writeUpdateCache (skip write — #404) AND latestReleaseVersion (skip the network check entirely — #397) when the dir is absent. A dir-present-but-stale/unreadable cache still falls through to the normal throttled fetch, so the everyday path is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
saadqbal
approved these changes
Jul 27, 2026
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.
Resolves a Cursor Bugbot finding on the cli promotion PR (#397, develop → main) — a follow-up to #404.
Update check unthrottled without config dir (Medium) — #404 correctly stopped
writeUpdateCachefrom recreating a wiped~/.tracebloc, butlatestReleaseVersionstill calledfetchLatestReleasewhenever the cache couldn't be read. On a fresh install (or after offboard) the config dir is absent, so the throttle cache can never be persisted — meaning every TTY command re-hit the GitHub releases API and could burn the fullupdateCheckTimeout, defeating the once-a-day throttle the failed-fetch path preserves elsewhere.Fix (reconciles both #404 and this): a single
configDirExistsgate answers "can the update-check throttle be persisted?" and is now used by both sides:writeUpdateCacheskips the write when the dir is absent (never resurrect a wiped dir — fix: Bugbot findings from promotion PR #397 (TLS floor + delete cache) #404). Unchanged behavior, refactored onto the shared gate.latestReleaseVersionskips the network check entirely when the dir is absent (nothing to persist, nothing to nudge — the CLI isn't set up or was offboarded), so it no longer hammers the API unthrottled (Release develop → main #397).The distinction the finding asked for:
"").Coverage added (reusing the existing httptest + temp-
TRACEBLOC_CONFIG_DIRscaffolding), no existing tests removed:TestLatestReleaseVersion_MissingConfigDirSkipsNetwork— absent dir ⇒ no fetch attempted (test server errors if hit) and the dir is not created. Fails on the pre-fix code, passes with it.TestLatestReleaseVersion_DirPresentNoCacheFetchesAndPersists— dir present, no cache ⇒ still fetches and persists the throttle (guards the normal path).(#397 (comment))
Lands on develop; the promotion PR head picks it up on the next sync and Bugbot re-reviews.
🤖 Generated with Claude Code
Note
Low Risk
Best-effort CLI update nudge only; behavior is tighter throttling and no config-dir side effects, with new httptest coverage.
Overview
Fixes unthrottled GitHub release checks when
~/.traceblocis missing (fresh install or after offboard). After #404 stoppedwriteUpdateCachefrom recreating the config dir,latestReleaseVersioncould still callfetchLatestReleaseon every TTY command because the throttle could never be saved—each run could hit the fullupdateCheckTimeout.A shared
configDirExistsgate now answers whether the throttle can be persisted:latestReleaseVersionreturns""and skips the network when the dir is absent;writeUpdateCacheuses the same helper (behavior unchanged from #404). When the dir exists but the cache is stale or missing, the normal once-per-day fetch and persist path is unchanged.Tests cover absent-dir (no HTTP, dir not created) and dir-present-with-no-cache (fetch + cache write).
Reviewed by Cursor Bugbot for commit 214ca84. Bugbot is set up for automated code reviews on this repo. Configure here.