refactor(queue): replace a dead store with the reason it is not needed - #139
refactor(queue): replace a dead store with the reason it is not needed#139rldyourmnd wants to merge 1 commit into
Conversation
Code scanning flagged `go/useless-assignment-to-local` at queue_intent.go:673. It is a true positive: `intent = existing` is the last statement of the `if exists` branch, `intent` is redeclared by `:=` on the next iteration, and nothing reads it in between. The line was not harmless, because it read as though the journal wanted the canonical record afterwards. It does not: the `exists` branch deliberately makes no write-back, since `journal.Intents` already holds `existing` and that record carries mutable lease state a freshly rebuilt `intent` does not. Overwriting it would discard progress. The comment now says that; the assignment said nothing and implied the opposite. Behaviour is unchanged — the store had no reader. The overlay is digest-pinned by `config/garm-derivative.yaml` and `scripts/build-garm-nddev.sh` verifies each file against it before building, so editing it without updating the pin would have failed later, in a different tool, for someone else. The manifest digest is updated and the script's generated region re-rendered with the repository's own command, `gha-fleet render-garm-build`, whose `-check` mode then reports `current: true`. Worth noting for anyone reading this file: `third_party/...` matches no packages in this module, so `go vet` and `go test` never see the overlay. It is compiled only inside `build-garm-nddev.sh`, against a GARM checkout. This finding came from the scanner, not from the test suite, because the test suite cannot reach it. Verified: `go vet ./...` clean, `go test -race ./...` every package ok, `go build -trimpath ./...` ok, `render-garm-build -check` current.
|
Closing this. The repository's own design says the change is not worth its price, and that is the right answer.
Not a build problem — every GARM package compiled and tested, Landing this would mean re-pinning I had already updated the two overlay-level digests through The alert is dismissed as |
Code scanning (enabled in #138) flagged
go/useless-assignment-to-localatqueue_intent.go:673. It is a true positive — the one true positive out of the 18 findings that scan produced.intentis redeclared by:=at the top of the next iteration and nothing reads it in between.Why the line was worse than harmless
It read as though the journal wanted the canonical record afterwards. It does not: the
existsbranch deliberately performs no write-back, becausejournal.Intentsalready holdsexisting, and that record carries mutable lease state a freshly rebuiltintentdoes not. Overwriting it would discard progress.So the assignment implied the opposite of the invariant it sat next to. The comment now states it. Behaviour is unchanged — the store had no reader.
The pin had to move with it
The overlay is digest-pinned in
config/garm-derivative.yaml, andbuild-garm-nddev.shrunsverify_digestagainst each file before building. Editing the file without updating the pin would have failed later, in a different tool, for whoever built next.Updated through the repository's own generator rather than by hand:
Worth knowing about this directory
./third_party/...matches no packages in this module:The overlay is compiled only inside
build-garm-nddev.sh, against a GARM checkout. Sogo vetandgo test -racehave never seen this file. This finding came from the scanner precisely because the test suite cannot reach it — which is an argument for having turned scanning on, and possibly an argument for covering the overlay some other way.Verification
go vet ./...clean ·go test -race ./...every package ok ·go build -trimpath ./...ok ·render-garm-build -checkcurrent.The other 17
Read individually and dismissed with the reasoning recorded on each alert: 12
go/log-injection(structured slog withNewJSONHandler— demonstrated that a newline in a value stays inside the JSON string), 1go/weak-sensitive-data-hashing(the SigV4X-Amz-Content-Sha256payload digest, which the protocol mandates), 3go/unhandled-writable-file-close(error paths that delete the file, and a flock sentinel never written to), 1actions/untrusted-checkout(already guarded bygit merge-base --is-ancestorbefore the checkout).