diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 0aa0f690..ea62afac 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -156,13 +156,10 @@ func retryableClient(cInput *client.ClientInput) (*client.APIClient, error) { // These cases come from the davinci-client-go library and may be subject to change case strings.Contains(err.Error(), "Error getting admin callback, got: status: 502, body:"): tflog.Info(ctx, "Found retryable error while initializing client. Retrying...") - fmt.Printf("Sign in retryable Error: %s\n", err.Error()) case strings.Contains(err.Error(), "Error getting SSO callback, got err: status: 502, body:"): tflog.Info(ctx, "Found retryable error while initializing client. Retrying...") - fmt.Printf("Sign in retryable Error: %s\n", err.Error()) case strings.Contains(err.Error(), "Auth Token not found, unsuccessful login, got: Found. Redirecting to https://console.pingone.com/davinci/index.html#/sso/callback/?error=AuthenticationFailed&error_description=unknownError2"): tflog.Info(ctx, "Found retryable error while initializing client. Retrying...") - fmt.Printf("Sign in retryable Error: %s\n", err.Error()) default: return nil, err } diff --git a/internal/service/davinci/data_source_application_test.go b/internal/service/davinci/data_source_application_test.go index c039998e..5d2c3e4a 100644 --- a/internal/service/davinci/data_source_application_test.go +++ b/internal/service/davinci/data_source_application_test.go @@ -3,7 +3,6 @@ package davinci_test import ( "fmt" "testing" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/pingidentity/terraform-provider-davinci/internal/acctest" @@ -11,11 +10,6 @@ import ( // TestAccDatasourceApplication_Slim - Depends on testAccResourceApplication_Slim_Hcl func TestAccDatasourceApplication_SlimByAppId(t *testing.T) { - // tflog.Info(ctx, "Rate limit hit, retrying...") - timeElapsed := 4 * time.Second - fmt.Println(timeElapsed) - fmt.Println(timeElapsed) - resourceBase := "davinci_application" resourceName := acctest.ResourceNameGen() dataSourceFullName := fmt.Sprintf("data.%s.%s", resourceBase, resourceName) diff --git a/internal/service/davinci/resource_application_flow_policy.go b/internal/service/davinci/resource_application_flow_policy.go index aedf37fa..3784f620 100644 --- a/internal/service/davinci/resource_application_flow_policy.go +++ b/internal/service/davinci/resource_application_flow_policy.go @@ -168,7 +168,6 @@ func resourceApplicationFlowPolicyRead(ctx context.Context, d *schema.ResourceDa } flatResp, err := flattenAppPolicy(resp, policyId) - // fmt.Printf("flatResp: %+v\n", flatResp) if err != nil { if strings.Contains(err.Error(), "Unable to find policy with id") { d.SetId("") diff --git a/internal/service/davinci/resource_connection_test.go b/internal/service/davinci/resource_connection_test.go index 8d836d2d..f83d2b7d 100644 --- a/internal/service/davinci/resource_connection_test.go +++ b/internal/service/davinci/resource_connection_test.go @@ -175,7 +175,6 @@ func TestAccResourceConnection_HeavyRead(t *testing.T) { // resourceFullName := fmt.Sprintf("%s.%s", resourceBase, resourceName) // hcl := testAccResourceConnection_HeavyRead_Hcl(resourceName, "heavy") - // fmt.Printf(`HCL: \n %s \n`, hcl) testAccResourceConnection_HeavyRead_Hcl(resourceName, "heavy") // resource.ParallelTest(t, resource.TestCase{ diff --git a/internal/service/davinci/resource_flow.go b/internal/service/davinci/resource_flow.go index 627f2dc3..fbb51212 100644 --- a/internal/service/davinci/resource_flow.go +++ b/internal/service/davinci/resource_flow.go @@ -795,17 +795,28 @@ func mapSubFlows(d *schema.ResourceData, flowJson string) (*string, error) { func expandSubFlowProps(subflowProps map[string]interface{}) (*dv.SubFlowProperties, error) { - sfp := subflowProps["subFlowId"].(map[string]interface{}) - sfpVal := sfp["value"].(map[string]interface{}) + sfp, ok := subflowProps["subFlowId"].(map[string]interface{}) + if !ok { + return nil, fmt.Errorf("Flow Validation Error: subFlowId key not found in subflow properties") + } + sfpVal, ok := sfp["value"].(map[string]interface{}) + if !ok { + return nil, fmt.Errorf("Flow Validation Error: subFlowId value not found in subflow properties") + } sfId := dv.SubFlowID{ Value: dv.SubFlowValue{ Value: sfpVal["value"].(string), Label: sfpVal["label"].(string), }, } - subflowVersionId := subflowProps["subFlowVersionId"].(map[string]interface{}) + subflowVersionId, ok := subflowProps["subFlowVersionId"].(map[string]interface{}) + if !ok { + return nil, fmt.Errorf("Flow Validation Error: subFlowVersionId not found in subflow properties") + } var sfvidString string - + if subflowVersionId["value"] == nil { + return nil, fmt.Errorf("Flow Validation Error: subFlowVersionId.value not found in subflow properties") + } switch subflowVersionId["value"].(type) { case int: sfvidString = strconv.Itoa(subflowVersionId["value"].(int)) @@ -814,14 +825,14 @@ func expandSubFlowProps(subflowProps map[string]interface{}) (*dv.SubFlowPropert case string: sfvidString = subflowVersionId["value"].(string) default: - return nil, fmt.Errorf("Error: subflow versionId is not a string or int") + return nil, fmt.Errorf("Flow Validation Error: subflow versionId is not a string or int") } sfv := dv.SubFlowVersionID{ Value: sfvidString, } if sfId.Value.Value == "" || sfv.Value == "" { - return nil, fmt.Errorf("Error: subflow value or versionId is empty") + return nil, fmt.Errorf("Flow Validation Error: subflow value or versionId is empty") } subflow := dv.SubFlowProperties{ SubFlowID: sfId, @@ -886,7 +897,15 @@ func validateFlowDeps(d *schema.ResourceData, diags *diag.Diagnostics) { // validate subflows if v.Data.ConnectorID == "flowConnector" && (v.Data.CapabilityName == "startSubFlow" || v.Data.CapabilityName == "startUiSubFlow") { foundSubflow := false - sfProp, _ := expandSubFlowProps(v.Data.Properties) + sfProp, err := expandSubFlowProps(v.Data.Properties) + if err != nil { + *diags = append(*diags, diag.Diagnostic{ + Severity: diag.Error, + Summary: "Error Validating flow_json", + Detail: err.Error(), + }) + return + } if subflows, ok := d.GetOk("subflow_link"); ok { sfList := subflows.(*schema.Set).List() for _, sfMap := range sfList {