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

xray_watch "description" field incorrectly set as null when value is emtpy string #293

Open
3 tasks done
EitanJoseph opened this issue Dec 24, 2024 · 2 comments
Open
3 tasks done
Assignees
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@EitanJoseph
Copy link

EitanJoseph commented Dec 24, 2024

Describe the bug
Terraform: 1.9.8
Artifactory: 7.59.9
Xray: 3.74.8

Providers:
jfrog/xray version: 3.0.3
jfrog/artifactory version: 12.3.2

When configuring an xray_watch with a description set to an empty string, for example

resource "xray_watch "WatchName" {
   name = "name"
   active = true
   description = ""
}

it appears that the actual value being set to the description is null because after applying this configuration then immediately checking terraform plan the output still shows that changes will be made ~ though it does not show any fields that will be changed.

Additionally, if you add an actual non-empty string to the description then configure the description as the empty string and check terraform plan you will see that it plans to set the description to null.

Requirements for and issue

  • A fully functioning terraform snippet that can be copy&pasted (no outside files or ENV vars unless that's part of the issue)
  • Your version of Artifactory and Xray (you can curl Artifactory version at $host/artifactory/api/system/version and Xray version at
    $host/xray/api/v1/system/version
  • Your version of terraform

Expected behavior
The expected behavior is that the description, weather null or empty string, should not display changes in terraform plan for a configuration with a null or empty string description. Otherwise this step incorrectly reports that our configuration is misaligned with the ground truth.

Additional context
Add any other context about the problem here.

@EitanJoseph EitanJoseph added the bug Something isn't working label Dec 24, 2024
@EitanJoseph EitanJoseph changed the title xray_watch "description" field incorrectly set as emtpy string xray_watch "description" field incorrectly set as null when value is emtpy string Dec 24, 2024
@alexhung
Copy link
Member

alexhung commented Jan 2, 2025

@EitanJoseph Thanks for the report! I've added this to our plan to investigate and fix.

@alexhung
Copy link
Member

alexhung commented Jan 2, 2025

@EitanJoseph The cause of this state drift is because Xray REST API for getting watch doesn't distinguish between empty string or null value. Whereas Terraform has separate concept of null and "".

When you update the watch using API with empty description, e.g. "description": "", the API accepts the empty string and update its value. Then on getting the watch, the API responses body will not contain the description field at all (there's no difference between empty value and not set value in Xray API). This leads to the provider unable to know whether the value is not defined in TF config, or it has an empty string.

Unfortunately there's no workaround for this (short of changing how the API works, which I've made the Xray team aware already).

After you've set the description attribute to empty and apply it, you will need to remove that attribute from your TF config in order to avoid state drift.

@alexhung alexhung added the wontfix This will not be worked on label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants