Skip to content

Commit 2631510

Browse files
committed
revert(survey): drop the three iteration-tracking computed fields
Walking back the additive part of this PR. Exposing current_iteration, current_iteration_start_date, and iteration_start_dates_json triggered a "Provider produced inconsistent result after apply" error in TestSurvey_ClearNumericLimits step 2: PostHog returns iteration_start_dates: [] (empty array) for non-recurring surveys, which jsonStringValue serialises as "[]", but the plan held null carried over by UseStateForUnknown. Reconciling that empty-array-vs-null mismatch is doable but adds non-trivial complexity (custom plan modifier, or normalising "[]" to null in the mapper) for what is purely cosmetic state — these fields aren't load-bearing for clearing or for any user-facing flow. Simpler to keep the surface area matching the original PR and revisit as a follow-up if anyone actually wants to read iteration progress through Terraform state.
1 parent 2ef6778 commit 2631510

3 files changed

Lines changed: 0 additions & 37 deletions

File tree

docs/resources/survey.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,8 @@ resource "posthog_survey" "feature_feedback" {
9999

100100
- `created_at` (String) RFC3339 creation timestamp of the survey.
101101
- `created_by_json` (String) JSON object describing the survey creator.
102-
- `current_iteration` (Number) Current iteration index for `recurring` surveys. Read-only.
103-
- `current_iteration_start_date` (String) RFC3339 start date of the current iteration. Read-only.
104102
- `id` (String) UUID of the survey.
105103
- `internal_targeting_flag_json` (String) JSON object describing the internal targeting feature flag returned by the API.
106-
- `iteration_start_dates_json` (String) JSON array of RFC3339 start dates for past and current iterations. Read-only.
107104
- `linked_flag_json` (String) JSON object describing the linked feature flag returned by the API.
108105
- `targeting_flag_json` (String) JSON object describing the targeting feature flag returned by the API.
109106

internal/resource/survey.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/hashicorp/terraform-plugin-framework/resource"
1111
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
1212
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
13-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
1413
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
1514
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1615
"github.com/hashicorp/terraform-plugin-framework/types"
@@ -68,9 +67,6 @@ type SurveyTFModel struct {
6867
LinkedFlagJSON types.String `tfsdk:"linked_flag_json"`
6968
TargetingFlagJSON types.String `tfsdk:"targeting_flag_json"`
7069
InternalTargetingFlagJSON types.String `tfsdk:"internal_targeting_flag_json"`
71-
CurrentIteration types.Int64 `tfsdk:"current_iteration"`
72-
CurrentIterationStartDate types.String `tfsdk:"current_iteration_start_date"`
73-
IterationStartDatesJSON types.String `tfsdk:"iteration_start_dates_json"`
7470
}
7571

7672
type SurveyOps struct{}
@@ -244,27 +240,6 @@ func (o SurveyOps) Schema() schema.Schema {
244240
Computed: true,
245241
MarkdownDescription: "JSON object describing the internal targeting feature flag returned by the API.",
246242
},
247-
"current_iteration": schema.Int64Attribute{
248-
Computed: true,
249-
MarkdownDescription: "Current iteration index for `recurring` surveys. Read-only.",
250-
PlanModifiers: []planmodifier.Int64{
251-
int64planmodifier.UseStateForUnknown(),
252-
},
253-
},
254-
"current_iteration_start_date": schema.StringAttribute{
255-
Computed: true,
256-
MarkdownDescription: "RFC3339 start date of the current iteration. Read-only.",
257-
PlanModifiers: []planmodifier.String{
258-
stringplanmodifier.UseStateForUnknown(),
259-
},
260-
},
261-
"iteration_start_dates_json": schema.StringAttribute{
262-
Computed: true,
263-
MarkdownDescription: "JSON array of RFC3339 start dates for past and current iterations. Read-only.",
264-
PlanModifiers: []planmodifier.String{
265-
stringplanmodifier.UseStateForUnknown(),
266-
},
267-
},
268243
},
269244
}
270245
}
@@ -491,9 +466,6 @@ func mapSurveyComputedFields(resp httpclient.Survey, model *SurveyTFModel) {
491466
model.LinkedFlagJSON = jsonStringValue(resp.LinkedFlag)
492467
model.TargetingFlagJSON = jsonStringValue(resp.TargetingFlag)
493468
model.InternalTargetingFlagJSON = jsonStringValue(resp.InternalTargetingFlag)
494-
model.CurrentIteration = util.PtrToInt64(resp.CurrentIteration)
495-
model.CurrentIterationStartDate = core.PtrToStringNullIfEmptyTrimmed(resp.CurrentIterationStartDate)
496-
model.IterationStartDatesJSON = jsonStringValue(resp.IterationStartDates)
497469
}
498470

499471
func applyNormalizedJSONString(apiData interface{}, current string, target *types.String) {

internal/resource/survey_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ func TestSurveyMapResponseToModel(t *testing.T) {
244244
ResponsesLimit: util.Int64Ptr(10),
245245
IterationCount: util.Int64Ptr(2),
246246
IterationFrequencyDays: util.Int64Ptr(7),
247-
IterationStartDates: []interface{}{testSurveyStartDate, testSurveySamplingStartDate},
248-
CurrentIteration: util.Int64Ptr(1),
249-
CurrentIterationStartDate: util.StringPtr(testSurveyStartDate),
250247
ResponseSamplingStartDate: util.StringPtr(testSurveySamplingStartDate),
251248
ResponseSamplingIntervalType: util.StringPtr("week"),
252249
ResponseSamplingInterval: util.Int64Ptr(2),
@@ -292,9 +289,6 @@ func TestSurveyMapResponseToModel(t *testing.T) {
292289
assert.JSONEq(t, `{"id":11}`, model.LinkedFlagJSON.ValueString())
293290
assert.JSONEq(t, `{"id":12}`, model.TargetingFlagJSON.ValueString())
294291
assert.JSONEq(t, `{"id":13}`, model.InternalTargetingFlagJSON.ValueString())
295-
assert.Equal(t, int64(1), model.CurrentIteration.ValueInt64())
296-
assert.Equal(t, testSurveyStartDate, model.CurrentIterationStartDate.ValueString())
297-
assert.JSONEq(t, `["2026-04-20T00:00:00Z","2026-04-22T00:00:00Z"]`, model.IterationStartDatesJSON.ValueString())
298292
}
299293

300294
func TestSurveyCRUDWrapperMethods(t *testing.T) {

0 commit comments

Comments
 (0)