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

Error: json.Unmarshal - invalid character '<' looking for beginning of value #275

Closed
tofkamp opened this issue Oct 7, 2023 · 4 comments · Fixed by #276
Closed

Error: json.Unmarshal - invalid character '<' looking for beginning of value #275

tofkamp opened this issue Oct 7, 2023 · 4 comments · Fixed by #276
Assignees
Labels

Comments

@tofkamp
Copy link

tofkamp commented Oct 7, 2023

I was working with ansible to try DSC, but a friend told me about terraform. So I am trying terraform with routeros 7.11.2
Created an own CA, and webserver. Added the CA to trusted store of ubuntu. Set this webserver certificate on www-ssl. Just trying to get a working example, by setting the /system/identity. I included the file, by adding ".txt" to the filename so github accepts it.
To reproduce the error : Put file in empty folder, terraform init; terraform plan; terraform apply

routeros_system_identity.identity: Creating...
routeros_interface_bridge.bridge: Creating...
╷
│ Error: json.Unmarshal - invalid character '<' looking for beginning of value
│
│   with routeros_interface_bridge.bridge,
│   on main.tf line 23, in resource "routeros_interface_bridge" "bridge":
│   23: resource "routeros_interface_bridge" "bridge" {
│
╵
╷
│ Error: json.Unmarshal - invalid character '<' looking for beginning of value
│
│   with routeros_system_identity.identity,
│   on main.tf line 29, in resource "routeros_system_identity" "identity":
│   29: resource "routeros_system_identity" "identity" {

It complains about invalid character "<", which is not in the file, nor in the examples on website.
I have installed terraform-routeros 1.18.2, on terraform 1.6.0. I thought it was an error in my system, but I have done the docker tutorial, and all went well. No errors.
main.tf.txt
What is going wrong ? Is the format changed ? Is there a program error ?

@vaerh
Copy link
Collaborator

vaerh commented Oct 7, 2023

Hi, I haven't gotten to version 7.11 yet and maybe it is the version that is causing the problem. But it should be checked at the lab.
Can I ask you to run ROS_LOG_COLOR=1 TF_LOG=debug terraform apply and post the output?

@tofkamp
Copy link
Author

tofkamp commented Oct 8, 2023

err.txt
In the output I saw the following:

error response body:
<!doctype html>
<html lang=en>
<title>Error 501 : Not Implemented</title>
<h1>Error 501 : Not Implemented</h1>

(it looked weird, so I put it in code, but it should be a quote)
Just to be sure it can work, I did: curl -k -u admin:admin https://bh1-k1-sw1.home.arpa/rest/system/resource
I got some json response with sensible numbers.

@tofkamp
Copy link
Author

tofkamp commented Oct 8, 2023

I found the cause of this error. It was the trailing "/" of the hosturl.
In the trace I noticed the dubble "//" after the hostname. Normal it is no problem, and other webservers just skips the extra "/".
For an user it is normal to put a "/" after the hostname. In order to prevent errors, or abandoning adoption of this provider, put a message in the manual, or do a check in the program, or correct it automatically.

@vaerh
Copy link
Collaborator

vaerh commented Oct 9, 2023

🎉 This issue has been resolved in version 1.18.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@vaerh vaerh added the released label Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants