Skip to content

Commit 1d52ce4

Browse files
committed
feat: enhance pipeline coupling errors for mixed generations
- Add contextual error messages when coupling apps from different generations - Include app name and generation in error output for better UX - Update pipeline documentation with generation compatibility requirements Addresses mixed-generation pipeline error handling work item.
1 parent b41661b commit 1d52ce4

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

docs/resources/pipeline.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ pipeline is created, and apps are added to different stages using
1717
[`heroku_pipeline_coupling`](./pipeline_coupling.html), you can promote app
1818
slugs to the next stage.
1919

20+
## Generation Compatibility
21+
22+
All apps in a pipeline must use the same Heroku platform generation (Cedar or Fir).
23+
Attempting to add apps from different generations will result in an error.
24+
2025
## Ownership & Access
2126

2227
Pipelines may be created as Personal or Team resources. Access to a pipeline

heroku/resource_heroku_pipeline_coupling.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"log"
7+
"strings"
78

89
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
910
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -67,7 +68,15 @@ func resourceHerokuPipelineCouplingCreate(d *schema.ResourceData, meta interface
6768

6869
p, err := client.PipelineCouplingCreate(context.TODO(), opts)
6970
if err != nil {
70-
return fmt.Errorf("Error creating pipeline: %s", err)
71+
// Enhance generation-related errors with app context
72+
errMsg := err.Error()
73+
if strings.Contains(errMsg, "same generation") {
74+
if app, appErr := client.AppInfo(context.TODO(), d.Get("app_id").(string)); appErr == nil {
75+
return fmt.Errorf("%s\n\nYour app '%s' is %s generation. Ensure all apps in the pipeline use the same generation (Cedar or Fir)",
76+
errMsg, app.Name, app.Generation.Name)
77+
}
78+
}
79+
return fmt.Errorf("error creating pipeline: %s", err)
7180
}
7281

7382
d.SetId(p.ID)
@@ -84,7 +93,7 @@ func resourceHerokuPipelineCouplingDelete(d *schema.ResourceData, meta interface
8493

8594
_, err := client.PipelineCouplingDelete(context.TODO(), d.Id())
8695
if err != nil {
87-
return fmt.Errorf("Error deleting pipeline: %s", err)
96+
return fmt.Errorf("error deleting pipeline: %s", err)
8897
}
8998

9099
return nil
@@ -95,7 +104,7 @@ func resourceHerokuPipelineCouplingRead(d *schema.ResourceData, meta interface{}
95104

96105
p, err := client.PipelineCouplingInfo(context.TODO(), d.Id())
97106
if err != nil {
98-
return fmt.Errorf("Error retrieving pipeline: %s", err)
107+
return fmt.Errorf("error retrieving pipeline: %s", err)
99108
}
100109

101110
d.Set("app_id", p.App.ID)

0 commit comments

Comments
 (0)