Skip to content

Commit 3b3b086

Browse files
authored
Merge pull request #18 from PostHog/vdekrijger-typo-corrections-post-export
chore: Small corrections after exporting the alerts / hog functions locally
2 parents 1c2df4d + db5518b commit 3b3b086

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

docs/resources/insight.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Manage PostHog insights via the insights endpoints.
2424
- `create_in_folder` (String) The folder where the insight is created.
2525
- `dashboard_ids` (Set of Number) List of dashboard ids which should contain the insight.
2626
- `deleted` (Boolean) Whether the insight is deleted (soft delete)
27-
- `derived_name` (String) Insight derived name.
27+
- `derived_name` (String) Insight derived name. This is auto-generated by PostHog when the name is not set.
2828
- `description` (String) Insight description.
2929
- `name` (String) Insight name.
3030
- `tags` (Set of String) List of tags to apply to the insight.

internal/resource/hog_function.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,19 @@ func (o HogFunctionOps) MapResponseToModel(ctx context.Context, resp httpclient.
308308
}
309309
}
310310

311-
if len(resp.Inputs) > 0 {
312-
normalized, err := normalizeJSONForState(resp.Inputs, model.InputsJSON.ValueString())
313-
if err != nil {
314-
diags.AddError("Failed to normalize inputs", err.Error())
315-
return diags
311+
// Only update inputs_json if user configured it (not template-provided)
312+
// This prevents inconsistent state when template provides default inputs
313+
if !model.InputsJSON.IsNull() {
314+
if len(resp.Inputs) > 0 {
315+
normalized, err := normalizeJSONForState(resp.Inputs, model.InputsJSON.ValueString())
316+
if err != nil {
317+
diags.AddError("Failed to normalize inputs", err.Error())
318+
return diags
319+
}
320+
model.InputsJSON = types.StringValue(normalized)
321+
} else {
322+
model.InputsJSON = types.StringValue("{}")
316323
}
317-
model.InputsJSON = types.StringValue(normalized)
318-
} else if !model.InputsJSON.IsNull() {
319-
model.InputsJSON = types.StringValue("{}")
320-
} else {
321-
model.InputsJSON = types.StringNull()
322324
}
323325

324326
if len(resp.Filters) > 0 {

internal/resource/insight.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
1313
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
1414
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
15+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1516
"github.com/hashicorp/terraform-plugin-framework/types"
1617
"github.com/posthog/terraform-provider/internal/httpclient"
1718
"github.com/posthog/terraform-provider/internal/resource/core"
@@ -56,7 +57,11 @@ func (o InsightOps) Schema() schema.Schema {
5657
},
5758
"derived_name": schema.StringAttribute{
5859
Optional: true,
59-
MarkdownDescription: "Insight derived name.",
60+
Computed: true,
61+
MarkdownDescription: "Insight derived name. This is auto-generated by PostHog when the name is not set.",
62+
PlanModifiers: []planmodifier.String{
63+
stringplanmodifier.UseStateForUnknown(),
64+
},
6065
},
6166
"description": schema.StringAttribute{
6267
Optional: true,

0 commit comments

Comments
 (0)