magodo / terraform-provider-restful

Terraform provider to manage RESTful resources
https://registry.terraform.io/providers/magodo/restful
Mozilla Public License 2.0
16 stars 5 forks source link

restful_operation fails when response content is empty #102

Closed cneu-bc closed 5 months ago

cneu-bc commented 5 months ago

Hi all,

I updated from v0.13.3 to v0.14.0. After the update I am getting the error "unexpected end of JSON input" in some restful_operation resources. After troubleshooting the issue I noticed that the response from the API is empty (no content, just header and status) on the resources failing with the error above.

Has anyone experienced this issue, too? Any fix for this planned?

Thanks and best regards, Chris

magodo commented 5 months ago

@cneu-bc What is the full error message? I thought this issue has been fixed in https://github.com/magodo/terraform-provider-restful/issues/99.

cneu-bc commented 5 months ago

I got the same/similar error message as in #99 . Please give me some time to rerun my module with v0.14.0 and paste the exact error message here. I need to ship stuff first as it is working with v0.13.3. I will come back to you next week

SneadeJacobM commented 5 months ago

@magodo I am seeing the same error when calling on this Microsoft API:

Full error message:

│ Error: Filter output during operation │ │ with module.entra_configuration.restful_operation.configure_authentication_flows_policy, │ on modules\entra_configuration\authentication_flows_policy.tf line 3, in resource "restful_operation" "configure_authentication_flows_policy": │ 3: resource "restful_operation" "configure_authentication_flows_policy" { │ │ unexpected end of JSON input

Within Microsoft's API documentation you can see this is the expected output: HTTP/1.1 204 No Content

The PATCH call I am making is successful, but it seems like it just doesn't know how to handle the empty output.

magodo commented 5 months ago

@SneadeJacobM This is because you have defined the output_attrs while the body is null.

SneadeJacobM commented 5 months ago

image

@magodo Good catch, I was admittedly tinkering with the output_attrs field to try to get it to accept a null response

I do still see an error even when I don't define any output_attrs, though -- instead of erroring on filtering it errors on evaluating. It also gives the same error when I remove the poll block.

Is there some way to inform the restful_operation to not look for an output?

magodo commented 5 months ago

@cneu-bc that said it is fixed in #100. Can you try to build from the main branch and test it out by following https://github.com/magodo/terraform-provider-restful/issues/95#issuecomment-2117488942? If it works, I'll create a patch release.

SneadeJacobM commented 5 months ago

Building from the latest main branch has solved the problem for me :)

magodo commented 5 months ago

v0.14.1 is now released, closing this issue.