How does the provider actually map retention_hours to the underlying /api/v2/screen-recording/policies endpoint when the API rejects values over 720?
The 03:15 JST deployment pipeline stalled again. State backup shows zero drift, but Terraform 1.9.8 paired with nice-cxone 1.19.2 throws a 422 Unprocessable Entity on the nice_cxone_screen_recording_policy resource. Validation logic inside the provider seems to clamp the integer, yet the API response body returns {“code”:“validation_error”,“message”:“retention_period exceeds maximum allowed threshold”}.
Tried dropping the value to 720 first. Pipeline still failed. Checked the raw HTTP request via TF_LOG=DEBUG. The payload sends “retention_hours”: 1440 despite the HCL block explicitly stating retention_hours = 720. Looks like the state file is caching the previous run’s value and the diff calculation skips the override. Forced a terraform apply -target=nice_cxone_screen_recording_policy.prod_screen_policy -refresh=false anyway. Same 422.
Cleared the local state cache, ran terraform init -upgrade, pulled the latest provider binary. The resource definition in the provider source still lists retention_hours as a computed attribute on read, but writable on create/update. API docs say the field maps to retention_period_days behind the scenes. Provider doesn’t handle the unit conversion.
Workaround attempted: switched to using the REST API directly via a null_resource with local-exec. That actually pushes the config through without errors. Terraform state imports it fine, but every subsequent plan marks it as tainted because the API returns retention_period_days instead of retention_hours. Drift detection goes haywire. Mic stays hot while debugging this.
Provider changelog for 1.19.0 mentions improved media policy handling but skipped screen recording entirely. State backup won’t save us if the schema keeps mutating the field name on every refresh.
resource "nice_cxone_screen_recording_policy" "prod_screen_policy" {
name = "Prod-Desktop-Recording"
retention_hours = 720
scope = "global"
}
Error trace points to client.go:342 during the PATCH request. Field mapping is completely off.