terraform-provider-nexus icon indicating copy to clipboard operation
terraform-provider-nexus copied to clipboard

Could not create privilege: id parameter must not be blank

Open mttradebyte opened this issue 2 years ago • 6 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Community Note

  • Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

1.0.0

Nexus Provider Version

1.21.0

Nexus Version

OSS 3.39.0-01

Affected Resource(s)/Data Source(s)

nexus_privilege

Terraform Configuration Files

resource "nexus_security_content_selector" "docker" {
  name       = "docker"
  expression = "path =^ \"/v2/aaaa/\""
}

resource "nexus_privilege" "docker_snapshot" {
  name             = "docker_snapshot"
  type             = "repository-content-selector"
  content_selector = "docker"
  repository       = "docker-snapshot"
  actions          = ["ADD", "EDIT", "READ"]

  depends_on = [ nexus_security_content_selector.docker ]
}

Debug Output/Panic Output

│ Error: could not create privilege "docker_snapshot": HTTP: 400, [ {
│   "id" : "PARAMETER format",
│   "message" : "must not be blank"
│ } ]
│
│   with nexus_privilege.docker_snapshot,
│   on privileges.tf line 129, in resource "nexus_privilege" "docker_snapshot":
│  129: resource "nexus_privilege" "docker_snapshot" {

Expected Behaviour

The privilege should have been created successfully.

Actual Behaviour

Errored out

Steps to Reproduce

No response

References

N/A

It should be noted that if the privilege is created in Nexus first, then imported, this configuration is acceptable. It just doesn't seem to work if creating from scratch. Additionally, id is a read-only attribute and cannot be set in the terraform config.

mttradebyte avatar Aug 23 '22 16:08 mttradebyte

The error seems to say the format parameter is missing, not the ID. Can you try to set the format to docker?

fmereu-bics avatar Aug 26 '22 09:08 fmereu-bics

Interesting. That seemed to resolve it, but it's listed as an optional attribute in the documentation, as well as when you import them, you don't need to provide the format and it doesn't change it. I guess the documentation needs to be updated to specify that it's not optional, however I'm not sure why importing it no longer requires it to be specified in your terraform though. Your terraform should always mirror reality, so having it missing after an import seems like an anti-pattern.

mttradebyte avatar Aug 26 '22 11:08 mttradebyte

This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 7 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

github-actions[bot] avatar Nov 25 '22 08:11 github-actions[bot]

/fresh Hi, we start to refactor the privilege resource. It would be splittet into own resources for each format, because the formats have different required parameters

anmoel avatar Nov 25 '22 08:11 anmoel

Nexus says:

"message" : "must not be blank"

and TF doesn't allow that message field.

Seq-73 avatar Jun 30 '23 07:06 Seq-73

I just got this error but with one addition. It wants a repository as well and not just the format. Both are listed as optional with the provider. Looking deeper it appears when trying to create a privilege in the UI only 2 out of the 6 privilege types actually require format. The rest don't even have format as an option.

We probably should change the documentation at the very minimum to note this and also later should probably handle this with code somehow

Required format:

  • Repository View
  • Repository Admin

Not applicable:

  • Application
  • Repository Content Selector
  • Script
  • Wildcard

Shocktrooper avatar Aug 19 '23 16:08 Shocktrooper