Skip to content

Commit 9673df5

Browse files
ipmbclaude
andcommitted
Fail immediately when an EOL stack is specified
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7a375a7 commit 9673df5

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

builder/build/appjson.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package build
33
import (
44
"context"
55
"encoding/json"
6+
"fmt"
67
"os"
78

89
"github.com/rs/zerolog/log"
@@ -119,7 +120,7 @@ func (a *AppJSON) Unmarshal() error {
119120
return err
120121
}
121122
if contains(EOLStacks, a.Stack) {
122-
log.Ctx(a.ctx).Warn().Str("stack", a.Stack).Msg("stack is end-of-life and no longer supported; upgrade to heroku-24")
123+
return fmt.Errorf("stack %q is end-of-life and no longer supported; upgrade to heroku-24", a.Stack)
123124
}
124125
return nil
125126
}

builder/build/appjson_test.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ func TestAppJsonMissing(t *testing.T) {
5959
func TestAppJsonStack(t *testing.T) {
6060
a := AppJSON{
6161
reader: func() ([]byte, error) {
62-
return []byte(`{"stack": "heroku-18"}`), nil
62+
return []byte(`{"stack": "heroku-22"}`), nil
6363
},
6464
ctx: testContext,
6565
}
6666
err := a.Unmarshal()
6767
if err != nil {
6868
t.Errorf("expected no error, got %s", err)
6969
}
70-
if a.Stack != "heroku-18" {
70+
if a.Stack != "heroku-22" {
7171
t.Errorf("expected heroku-22, got %s", a.Stack)
7272
}
7373
}
@@ -90,22 +90,19 @@ func TestAppJsonBuilders(t *testing.T) {
9090
}
9191
}
9292

93-
func TestAppJsonEOLStackWarning(t *testing.T) {
93+
func TestAppJsonEOLStackError(t *testing.T) {
9494
for _, stack := range EOLStacks {
95-
var buf strings.Builder
96-
logger := zerolog.New(&buf)
97-
ctx := logger.WithContext(context.Background())
9895
a := AppJSON{
9996
reader: func() ([]byte, error) {
10097
return []byte(`{"stack": "` + stack + `"}`), nil
10198
},
102-
ctx: ctx,
99+
ctx: testContext,
103100
}
104-
if err := a.Unmarshal(); err != nil {
105-
t.Fatalf("stack %s: unexpected error: %s", stack, err)
106-
}
107-
if !strings.Contains(buf.String(), "end-of-life") {
108-
t.Errorf("stack %s: expected EOL warning in log output, got: %s", stack, buf.String())
101+
err := a.Unmarshal()
102+
if err == nil {
103+
t.Errorf("stack %s: expected error for EOL stack, got nil", stack)
104+
} else if !strings.Contains(err.Error(), "end-of-life") {
105+
t.Errorf("stack %s: expected end-of-life error, got: %s", stack, err)
109106
}
110107
}
111108
}

0 commit comments

Comments
 (0)