fix(templates): revert templates.go change from #1781 (duplicate of #1777)
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 7s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 21s
CI / Detect changes (pull_request) Successful in 18s
CI / Python Lint & Test (pull_request) Successful in 19s
E2E API Smoke Test / detect-changes (pull_request) Successful in 23s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 18s
E2E Chat / detect-changes (pull_request) Successful in 19s
Harness Replays / detect-changes (pull_request) Successful in 18s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 17s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 19s
Lint no tenant GITEA or GITHUB token write / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 7s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 11s
gate-check-v3 / gate-check (pull_request) Successful in 12s
qa-review / approved (pull_request) Failing after 10s
sop-checklist / na-declarations (pull_request) N/A: (none)
security-review / approved (pull_request) Failing after 10s
sop-checklist / review-refire (pull_request) Has been skipped
sop-checklist / all-items-acked (pull_request) Successful in 12s
sop-tier-check / tier-check (pull_request) Successful in 8s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m7s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 4s
CI / Canvas (Next.js) (pull_request) Successful in 19s
E2E Chat / E2E Chat (pull_request) Successful in 19s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 6s
Harness Replays / Harness Replays (pull_request) Successful in 13s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 1m52s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2m31s
CI / Platform (Go) (pull_request) Successful in 7m23s
CI / all-required (pull_request) Successful in 25m59s
audit-force-merge / audit (pull_request) Successful in 11s

PR #1781 relaxed the runtime allowlist to permit empty runtime
through, intending to preserve TestTemplatesList_LegacyTopLevelModel's
backward-compat surface. But PR #1777 (`a492d111`, landed before
#1781) had already addressed the same test failure via the opposite
approach: update fixtures to include valid runtime values, leaving
templates.go strict.

#1781 was written without grepping for parallel in-flight fixes
(operator error during the 2026-05-24 CTO-bypass session). Both
fixes ended up on main, with #1781 silently reverting #1777's
strictness intent for real production legacy templates while no
test now covers that path.

This revert restores templates.go to #1777's intended strict state.
templates_test.go fixtures (already updated by #1777) remain
unchanged and continue to pass. The narrow-catalog filter rejects
empty-runtime templates as #1777's product decision dictated.

Verified locally:
- `go test -run '^TestTemplatesList_' ./internal/handlers/` green
- `go vet ./...` clean
This commit is contained in:
2026-05-23 23:58:47 -07:00
parent 0fc1649a0c
commit b903c4d24e
@@ -204,18 +204,9 @@ func (h *TemplatesHandler) List(c *gin.Context) {
return
}
runtime := strings.TrimSuffix(strings.TrimSpace(raw.Runtime), "-default")
// Empty runtime is the legacy / pre-runtime_config shape: those
// templates declare `model:` at the top level and never set
// runtime. TestTemplatesList_LegacyTopLevelModel pins the
// backward-compat contract that they keep surfacing. The
// narrow-catalog filter (a5211050) applies only when a runtime
// is declared — declared runtimes must be in the allowlist;
// absent ones fall through unchanged.
if runtime != "" {
if _, ok := knownRuntimes[runtime]; !ok {
log.Printf("templates list: skip %s: unsupported runtime %q", id, raw.Runtime)
return
}
if _, ok := knownRuntimes[runtime]; !ok {
log.Printf("templates list: skip %s: unsupported runtime %q", id, raw.Runtime)
return
}
// Model comes from either top-level (legacy) or runtime_config.model (current).