Open fancybear-dev opened 3 weeks ago
Based on this issue (https://github.com/BetterStackHQ/terraform-provider-better-uptime/issues/19) and API docs (https://betterstack.com/docs/uptime/api/create-a-new-monitor/#example-curl) I suspect the provider does insufficient validation for the input value of request_headers of the betteruptime_monitor resource. We have a condition in place that results in a null value being passed, which is accepted - but seemingly not processed properly by the provider -> resulting in the conversion panic. Testing this now.
I find the API odd in general as well - never seen a data structure like this for this purpose;
"request_headers": [
{
"name": "X-Custom-Header",
"value": "custom header value"
}
]
This is overly complex to simply pass headers, something like;
"request_headers": {
header_key: header_value,
header_key2: header_value2
}
makes more sense to me personally - it also reads better in places like Terraform. I'm sure there are reasons for the existing solution, but thought I'd share regardless.
Right now in Terraform I do the conversion like this (to pass it 1:1 to the resource) - but this conversion in itself is the thing I find odd but it's what it is because the API expects it like this;
headers = {
"Authorization" = "whatever"
"magic" = "tree"
}
request_headers = [
for header_key, header_value in local.headers: {
name = header_key
value = header_value
}
]
Managed to work around the issue by ensuring the input value is as expected, and am now receiving the error that is correct - but should also be catched imo in the provider. If not catched in the provider at plan time, it creates overhead for developers when it fails at apply time. The provider should reflect what the API is validating on.
In any case, solved my issues - but will leave this issue open as I'm curious what your thoughts are.
What I would like most, is if null is accepted to be passed to the provider - to allow for conditional request_headers. Right now it's either a provider panic or the API that does not accept it -> so I'm currently always passing a (bogus) header.
Hello @fancybear-dev, thank you for the detailed report 🙌
While I can't provide any ETA on this, we'd like to fix the provider panicking in this case. The request_headers field should be easier to work with there. Thanks again for reporting it and all the details 👍
Hi,
We're running into what seems to be a provider bug, but we're unsure as of yet.
Resources it seems to affect;
I have not been able to reproduce it outside of our production environment yet, but also cannot share those details. These kinds of errors can happen in case of a lack of memory, we have not validated this yet. It would be unusual, given we run on a 32GB RAM environment that is very lean. I'm aware this is limited information to do anything with, but wanted to report it regardless and keep you in the loop in case we find a root cause / fix. If this is something that someone else has seen / if this is a known issue - I'd eagerly would want to know.