feat: upgrade all deps to latest (Go 1.24), fix bugs/races/leaks, expand test coverage - #11
Merged
Merged
Conversation
…and tests Dependencies: - Upgrade every direct and transitive dependency to its latest Go 1.24-compatible release; bump go directive 1.23 -> 1.24 and CI to match. Races and leaks: - Guard the per-adapter package singleton with a mutex (New/Get/Set raced). - End implicitly-created APM transactions when the operation span ends (they were never ended: telemetry lost, pooled objects leaked). - s3: close GetObject response body; use UploadWithContext. - redis/mongodb/sftp New: close client/connection on ping or validation failure (connection pools, topology goroutines, SSH sessions leaked). - file: close the CreateIfNotExist pre-created handle (fd-per-call leak); surface write-path Close errors. - Use retrier.RunCtx so connection retries honor ctx cancellation. Correctness: - storage: fan-out helpers no longer drop zero-valued results (WithRemoveZeroValues(false)); RetrieveFromMany aggregates all errors; Mock methods error instead of panicking when unset. - sql (postgres/sqlite/mysql): validate target before interpolating into default Count/List queries (SQL injection); Update of a missing row is 404; postgres uses its registered goqu dialect. - mongodb: List no longer nil-panics on nil params; Update returns 404 when nothing matched. - elasticsearch: Count emits track_total_hits again (was capped at 10k via a value-vs-pointer assertion); routing condition un-inverted; remove double TraceError in Query; drop dead post-defer body check. - dynamodb: Count paginates LastEvaluatedKey with Select COUNT; sanitize expression placeholders (dashes/dots in attribute names); List omits invalid Limit 0; New keeps region with a custom config. - s3: New returns an error instead of log.Fatal; drop stale singleton short-circuit (wrong-bucket reuse); Retrieve maps missing keys to 404. - sftp: accept documented host:port addr; Count honors the search glob without mutating caller params. - redis: Count uses SCAN (not blocking KEYS) and treats empty search as match-all; Update failures hit the update (not count) metric. - memory: Count/List honor the Search glob; Retrieve errors on non-[]byte values; Create rejects empty ids (redis too). - file: Create no longer nil-panics on nil params and resolves the Target fallback in CreateIfNotExist; Retrieve metric attribution fixed. - customapm.TraceError nil-safe; dynamodb vet fix (non-constant format). Tests: - New offline suites (happy/bad/edge, all under -race): memory and file adapter CRUD + concurrency + fd-leak regression, sqlite end-to-end CRUD + injection guard + update-404, storage fan-out zero-value/error aggregation + Mock guards, customapm transaction lifecycle via a recording tracer, dynamodb expression builders, elasticsearch query builder, sftp addr parsing. - Lint: green with the repo config (usetesting autofixes from the Go 1.24 bump included); aws-sdk-go v1 deprecation excluded pending a v2 migration. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CwjMuEcMQgwWfQF7JbjB6M
thalesfsp
marked this pull request as ready for review
July 8, 2026 20:23
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.
Summary
Upgrades every dependency to its latest Go 1.24-compatible release, fixes the bugs, data races, and resource leaks found in a full-codebase audit, and adds offline unit/e2e test suites (happy, bad, and edge paths) that run under
-racewith no external infrastructure.Dependency upgrades
godirective 1.23 → 1.24; CI workflow bumped to Go 1.24 to match.aws-sdk-gov1 andmongo-driverv1 are deprecated upstream in favor of v2 modules with different APIs. Migrating the s3/dynamodb/mongodb storages is a separate, breaking effort (same forgo-elasticsearchv9).Races & leaks fixed
singletonnow mutex-guarded (concurrentNew/Get/Setraced in all 11 adapters).customapm.Tracenow returns a span wrapper whoseEnd()also ends a transaction it created.s3.Retrieveleaked the HTTP response body on every call;s3.Create/Updatenow useUploadWithContext.redis.New/mongodb.New/sftp.Newleaked connection pools, topology goroutines, and SSH sessions when ping/validation failed (mirrors the earlier SQL-adapter fix from fix(sql): close the opened client on New's post-open error paths (connection-handle leak) #10).file.CreatewithCreateIfNotExistleaked one fd per call; write paths now surfaceCloseerrors.retrier.RunCtx, so a canceled context no longer sleeps through ~70s of backoff.Correctness fixes
concurrentloopdefaults toRemoveZeroValues: true) — a legitimate count of0, an all-zero document, or an empty generated ID silently vanished;RetrieveFromManyreturned only one nondeterministic error;Mockmethods panicked (crashing the process from inside worker goroutines) when unset.targetwas interpolated verbatim into defaultCount/Listqueries — SQL injection; now validated as an identifier.Updateof a missing row silently succeeded, now 404 likeRetrieve. postgres now uses its registered goqu dialect.CountpassedListAnyby value to a pointer-only assertion, sotrack_total_hitswas dropped and counts silently capped at 10,000; routing condition was inverted (== nilinstead of!= nil);Querydouble-counted failures.Countread only the first 1MB scan page (silent undercount) — now paginates withSelect: COUNT; expression placeholders are sanitized so attribute names with dashes/dots don't throwValidationException;Listno longer sends invalidLimit: 0;Newno longer discardsregionwhen a custom config lacks one; vet-flagged non-constant format string fixed.List(ctx, target, &out, nil)panicked on nil params;Updatematching nothing now returns 404.Newcalledlog.Fatal(killing the host process) on session error, and silently returned a cached singleton configured for a different bucket;RetrievemapsNoSuchKeyto 404; wrong failure-metric attributions fixed.host:portaddress form never worked (url.Parsemangled it);Countoverwrote the caller's search pattern and mutated the caller's params struct — now honors the glob without mutation.Countused blockingKEYS(nowSCAN) and returned 0 for an empty pattern (now match-all);Updatefailures incremented the count metric; empty-idCreaterejected.Count/Listignored the documentedSearchglob;Retrievesilently succeeded on non-[]bytevalues; empty-idCreaterejected.Createpanicked on nil params (deref before nil-check) and ranCreateIfNotExistagainst the raw arg instead of the resolvedTargetfallback;Retrievefailures were attributed to the delete metric.customapm.TraceErrornil-safe;shared.ErrorContainsno longer vacuously matches on an empty expected substring; test HTTP server no longer sleeps 1s per call.Tests added (all offline, all
-race)CreateIfNotExist, fd-leak regression (/proc/self/fd), 404 + metric-attribution regressions, glob Count/List, idempotent delete.track_total_hitsby pointer and value, from/size emission, JSON validity.Existing integration suites (Mongo/Redis/ES/Postgres services) run in CI as before; they couldn't be executed in this sandbox (no Docker daemon), so please let CI validate those paths.
go test -short -race ./...: 15/15 packages;golangci-lint: clean)🤖 Generated with Claude Code
https://claude.ai/code/session_01CwjMuEcMQgwWfQF7JbjB6M
Generated by Claude Code