Skip to content

Commit 7208907

Browse files
committed
Fix some comments and null handling
1 parent 6bbcf51 commit 7208907

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

internal/provider/profiles_warehouse_resource.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,18 @@ func (r *profilesWarehouseResource) Update(ctx context.Context, req resource.Upd
239239
return
240240
}
241241

242+
if (plan.SchemaName.IsNull() || plan.SchemaName.IsUnknown()) && !state.SchemaName.IsNull() {
243+
resp.Diagnostics.AddError(
244+
fmt.Sprintf("Unable to update Profiles Warehouse (ID: %s)", plan.ID.ValueString()),
245+
"Cannot unset schema name",
246+
)
247+
248+
return
249+
}
250+
242251
// Only send schemaName to API if it differs from the remote state.
243252
// This prevents API failures when the schema name already exists in the warehouse.
244-
// The Segment API fails if we send a schemaName that matches the current configuration.
253+
// The Segment API fails if we send a schemaName that matches the current configuration
245254
// even though it should be a no-op. This handles all cases:
246255
// 1. Both null/undefined: Equal() returns true, schemaName stays nil (not sent).
247256
// 2. Both have same value: Equal() returns true, schemaName stays nil (not sent).

internal/provider/profiles_warehouse_resource_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ func TestDetermineSchemaNameForUpdate(t *testing.T) {
554554
name: "plan_null_state_has_value",
555555
planSchemaName: types.StringNull(),
556556
stateSchemaName: types.StringValue("my-schema"),
557-
expectedResult: nil, // null pointer, not the actual value
558-
description: "Plan null, state has value - should send schemaName to API",
557+
expectedResult: nil,
558+
description: "Plan null, state has value - should send nil schemaName to API",
559559
},
560560
{
561561
name: "plan_has_value_state_null",

0 commit comments

Comments
 (0)