Skip to content

Stability: bugfixes, panic guards and cleanup#864

Merged
brainexe merged 9 commits into
masterfrom
stability
Jun 21, 2026
Merged

Stability: bugfixes, panic guards and cleanup#864
brainexe merged 9 commits into
masterfrom
stability

Conversation

@brainexe

Copy link
Copy Markdown
Member

Summary

A pass over the bot focused on robustness: fixing latent bugs, adding bounds/nil guards against panics, closing concurrency holes, and modernizing a few spots. 8 themed commits, 31 files. New unit tests cover the storage, token-truncation, retry, and ripeatlas fixes. make test, make test-race, and make lint all pass.

Notable bug fixes

  • storage/chain: the memory cache was populated on read error instead of success (inverted condition) — it never cached good reads and poisoned the cache with zero values on failures. Also propagate redis/file Write/ReadDir errors that were previously swallowed, and guard currentStorage with the existing mutex.
  • openai/truncate: message truncation walked oldest→newest and dropped the most recent messages — including the current user prompt — when over budget. Now keeps the tail.
  • cron: command list was indexed positionally against scheduler entries, which drifts if any cron fails to register. Entries are now mapped by EntryID; the scheduler is also stopped on shutdown.
  • pool: GetLocks returned internal pointers (callers could mutate pool state); it now returns value snapshots. The expiry-warning flag was set on a copy and had no effect — now done atomically under lock. Unlock returns ErrNoLockedResourceFound instead of silently succeeding.

Panic guards

Bounds/nil checks before indexing in: interaction block actions, message timestamps (MessageRef.GetTime), ripeatlas hop results, retry history, traceroute measurements, and nil jira Priority/Status.

Concurrency

  • Jenkins job-watcher stopper map is now mutex-guarded.
  • Storage global accessor locking tidied.

⚠️ Behavior change to review

  • jenkins/start_build: the build-start poll was an unbounded loop. It now respects context cancellation and gives up after 5 minutes. A job that takes longer than 5 minutes just to leave the queue will now error instead of hanging the goroutine forever. Flagging in case any jobs have long queue times.

brainexe added 9 commits June 21, 2026 11:35
- chainStorage.Read cached to memory on error instead of success (inverted
  condition); now promotes successful persistent reads and no longer poisons
  the memory layer with zero values on failure
- fileStorage.GetKeys propagates ReadDir errors (empty list only for a
  missing collection dir)
- redisStorage.Write returns the HSet error instead of always nil
- InitStorage/SetStorage/getStorage guard currentStorage with globalMu
- handleInteraction: skip block actions with an empty BlockActions slice
- MessageRef.GetTime: handle timestamps without a microsecond part
- ripeatlas: bounds-check hop Result entries before indexing [0..2]
- retry: error out when the loaded history has no messages
- traceroute: error on empty measurement list; raise scanner buffer to 1MB
- watcherCommand: guard the stopper map with a mutex
- cron: map cron EntryID to its config so listing/scheduling stay aligned
  even when some crons fail to register; stop the scheduler on shutdown
startJob polled the queued build in an unbounded loop; now it respects
context cancellation and gives up after 5 minutes instead of hanging the
goroutine forever
add priorityName/statusName helpers so tickets without a priority or status
no longer panic on a nil pointer dereference
- truncateMessages walked oldest->newest and dropped the most recent
  messages (including the current prompt); now walks newest->oldest and
  keeps the tail
- gate verbose request logging behind cfg.LogTexts
- raise the stream scanner buffer to 1MB and surface scanner errors
- use slices.Reverse for channel history ordering
- GetLocks returns value copies so callers can't mutate internal state by
  accident
- Unlock returns ErrNoLockedResourceFound instead of silently succeeding
- mark the expiry warning via markWarningSent under the lock (the previous
  copy mutation had no effect)
- drop the redundant delete-before-write in ExtendLock
- JenkinsJobs.GetSortedNames uses slices.Sorted(maps.Keys)
- random splits options with strings.Fields to ignore extra whitespace
- sendMessage uses GetUser() consistently
- list_command only replies on an actual pin error
- then_command uses the mutex-guarded GetRunningCommand helper
- request uses the unicode reaction convention and fixes help examples
- check and log the previously-ignored Socket.Ack error
- rewrite two if-else chains as switch statements
- use context-aware exec/http APIs in vcs and openai clients
- fix overflow-prone rune conversion in storage test (strconv.Itoa)
- exclude false positives in .golangci.yml: G117 on config secret
  field names, G705/G706 taint in the CLI/test mock, musttag on
  config dumps, noctx in tests, and pre-existing package names
@brainexe brainexe merged commit a06f24b into master Jun 21, 2026
12 checks passed
@brainexe brainexe deleted the stability branch June 21, 2026 18:51
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