From ef2b3a7263df4dab1449b796f2e6aa61bc5e8ca7 Mon Sep 17 00:00:00 2001 From: Ethan <39577870+ethanndickson@users.noreply.github.com> Date: Wed, 22 Apr 2026 00:11:09 +1000 Subject: [PATCH] fix: rebuild modeloptionsgen when codersdk changes (#24543) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `_gen/bin/modeloptionsgen` reflects over `codersdk` struct tags, but reflection doesn't read source — Go struct tags are compile-time string literals folded into the type descriptor and emitted into the binary's `.rodata` section. `reflect.TypeOf(...).Field(i).Tag.Get("enum")` reads from that baked-in table; the generator cannot consult `codersdk/chats.go` on disk even if it wanted to. That means the binary has to be rebuilt whenever those tags change. The existing Makefile rule only depends on `scripts/modeloptionsgen/*.go`, and the JSON target lists the binary as an order-only prereq, so `make gen` happily runs the stale binary after edits to `codersdk/chats.go` and writes outdated enum values. Fix: add `$(wildcard codersdk/*.go)` to the binary's prereqs, matching `clidocgen`. The whole-package wildcard is deliberate — a narrower prereq would break if someone splits `chats.go`. Cost is negligible: Go's per-package build cache means unrelated edits recompile one package and re-link, and the JSON target's own prereqs are unchanged so it doesn't regenerate. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6a8feb0478..bb70709683 100644 --- a/Makefile +++ b/Makefile @@ -151,7 +151,7 @@ _gen/bin/metricsdocgen-scanner: $(wildcard scripts/metricsdocgen/scanner/*.go) | @mkdir -p _gen/bin go build -o $@ ./scripts/metricsdocgen/scanner -_gen/bin/modeloptionsgen: $(wildcard scripts/modeloptionsgen/*.go) | _gen +_gen/bin/modeloptionsgen: $(wildcard scripts/modeloptionsgen/*.go) $(wildcard codersdk/*.go) | _gen @mkdir -p _gen/bin go build -o $@ ./scripts/modeloptionsgen