From 6fd75637df52ff87edabb740c20935927eec59de Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Wed, 5 Nov 2025 10:25:28 +0000 Subject: [PATCH] PSS: Gate experimental logic behind feature flag (#37872) This is a partial backport of #37868 --- internal/command/init_run.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/command/init_run.go b/internal/command/init_run.go index a030e856d9..fbc45794f2 100644 --- a/internal/command/init_run.go +++ b/internal/command/init_run.go @@ -142,16 +142,28 @@ func (c *InitCommand) run(initArgs *arguments.Init, view views.Init) int { return 1 } - if !c.Meta.AllowExperimentalFeatures && rootModEarly.StateStore != nil { + if !(c.Meta.AllowExperimentalFeatures && initArgs.EnablePssExperiment) && rootModEarly.StateStore != nil { // TODO(SarahFrench/radeksimko) - remove when this feature isn't experimental. // This approach for making the feature experimental is required // to let us assert the feature is gated behind an experiment in tests. // See https://github.com/hashicorp/terraform/pull/37350#issuecomment-3168555619 + + detail := "Pluggable state store is an experiment which requires" + if !c.Meta.AllowExperimentalFeatures { + detail += " an experimental build of terraform" + } + if !initArgs.EnablePssExperiment { + if !c.Meta.AllowExperimentalFeatures { + detail += " and" + } + detail += " -enable-pluggable-state-storage-experiment flag" + } + diags = diags.Append(earlyConfDiags) diags = diags.Append(&hcl.Diagnostic{ Severity: hcl.DiagError, - Summary: "Unsupported block type", - Detail: "Blocks of type \"state_store\" are not expected here.", + Summary: "Pluggable state store experiment not supported", + Detail: detail, Subject: &rootModEarly.StateStore.TypeRange, }) view.Diagnostics(diags)