Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better validation error of custom severity #253

Closed
oallauddin opened this issue Sep 30, 2024 · 1 comment · Fixed by #254
Closed

Better validation error of custom severity #253

oallauddin opened this issue Sep 30, 2024 · 1 comment · Fixed by #254
Assignees
Labels
bug Something isn't working

Comments

@oallauddin
Copy link

oallauddin commented Sep 30, 2024

** Example terraform

locals {
  team = "xyz"
}
resource "project" "project" {
  key          = local.team
  display_name = "${upper(local.team)} Project"
  description  = "${upper(local.team)} Project"

  admin_privileges {
    manage_members   = true
    manage_resources = true
    index_resources  = true
  }
}

resource "xray_license_policy" "license_policy" {
  name        = "${local.team}-license-policy"
  description = "${upper(local.team)} License Policy"
  type        = "license"
  project_key = local.team

  rule {
    name     = "${local.team}-license-rule"
    priority = 1

    criteria {
      allow_unknown            = false
      multi_license_permissive = true
    }

    actions {
      block_release_bundle_distribution  = false
      block_release_bundle_promotion     = false
      custom_severity                    = "medium"
      notify_watch_recipients            = false
      notify_deployer                    = false
      create_ticket_enabled              = false
      fail_build                         = true
      build_failure_grace_period_in_days = 0

      block_download {
        unscanned = false
        active    = false
      }
    }
  }
}

terraform {
  backend "local" {
    path = "terraform.tfstate"
  }
  required_providers {
    artifactory = {
      source  = "jfrog/artifactory"
      version = "11.9.2"
    }
    xray = {
      source  = "jfrog/xray"
      version = "2.11.2"
    }
    project = {
      source  = "jfrog/project"
      version = "1.8.0"
    }
  }
  required_version = ">= 1.6.2"
}

** Example error

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to xray_license_policy.license_policy, provider "provider[\"registry.terraform.io/jfrog/xray\"]" produced an unexpected new value: .rule: planned set element
│ cty.ObjectVal(map[string]cty.Value{"actions":cty.SetVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"block_download":cty.SetVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"active":cty.False,
│ "unscanned":cty.False})}), "block_release_bundle_distribution":cty.False, "block_release_bundle_promotion":cty.False, "build_failure_grace_period_in_days":cty.NumberIntVal(0),
│ "create_ticket_enabled":cty.False, "custom_severity":cty.StringVal("medium"), "fail_build":cty.True, "mails":cty.NullVal(cty.Set(cty.String)), "notify_deployer":cty.False,
│ "notify_watch_recipients":cty.False, "webhooks":cty.NullVal(cty.Set(cty.String))})}), "criteria":cty.SetVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"allow_unknown":cty.False,
│ "allowed_licenses":cty.NullVal(cty.Set(cty.String)), "banned_licenses":cty.NullVal(cty.Set(cty.String)), "multi_license_permissive":cty.True})}), "name":cty.StringVal("alp-license-rule"),
│ "priority":cty.NumberIntVal(1)}) does not correlate with any element in actual.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Is your feature request related to a problem? Please describe.
"medium" was used instead of "Medium" for custom severity in license policy. Error returned did not point out the problem.

Describe the solution you'd like
Friendlier errors when validation errors are encountered.
Something like. Validation Error: "medium" is not a valid custom severity. Valid values are "Low", "Medium" or "High"
I thought the REST API would return the validation errors.
Maybe we are swallowing and not displaying them in the provider?

@alexhung
Copy link
Member

@oallauddin Thanks for the report! I've added this to our plan.

@alexhung alexhung added the bug Something isn't working label Sep 30, 2024
alexhung added a commit that referenced this issue Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants