Skip to content

Commit 8f0d71c

Browse files
fix: make ai_task.id change backwards compatible
1 parent c2c443b commit 8f0d71c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

provider/ai_task.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"os"
66

7+
"github.com/google/uuid"
78
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
89
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
910
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -27,10 +28,17 @@ func aiTaskResource() *schema.Resource {
2728

2829
Description: "Use this resource to define Coder tasks.",
2930
CreateContext: func(c context.Context, resourceData *schema.ResourceData, i any) diag.Diagnostics {
31+
var diags diag.Diagnostics
32+
3033
if idStr := os.Getenv("CODER_TASK_ID"); idStr != "" {
3134
resourceData.SetId(idStr)
3235
} else {
33-
return diag.Errorf("CODER_TASK_ID must be set")
36+
resourceData.SetId(uuid.NewString())
37+
38+
diags = append(diags, diag.Diagnostic{
39+
Severity: diag.Warning,
40+
Summary: "`CODER_TASK_ID` should be set, this will be an error in the future",
41+
})
3442
}
3543

3644
if prompt := os.Getenv("CODER_TASK_PROMPT"); prompt != "" {
@@ -58,7 +66,7 @@ func aiTaskResource() *schema.Resource {
5866
return diag.Errorf("'app_id' must be set")
5967
}
6068

61-
return nil
69+
return diags
6270
},
6371
ReadContext: schema.NoopContext,
6472
DeleteContext: schema.NoopContext,

0 commit comments

Comments
 (0)