Introduction
Problem
In Terraform Enterprise, on a workspace when adding a variable the UI is throwing an error:
Error saving variable
Unexpected token '<', "<html><hea"... is not valid JSON
as it can be seen on the images below:
To check the cause of the error, please collect a HAR file depending on your browser.
Prerequisites
- Terraform Enterprise
- Firewall/WAF enabled
Cause
To determine the cause, the HAR file has been reviewed and the following error message has been identified:
"content": {
"size": 267,
"mimeType": "text/html",
"compression": 0,
"text": "<html><head><title>Request Rejected</title></head><body>Your request was rejected. Please contact Servicedesk, quoting <reference-number> and request ID: <id-of-the-issue><br><br><a href='javascript:history.back();'>[Go Back]</a></body></html>"
},
The request is being rejected due to the customer's WAF policies and rules.
NOTE: Take it as an example, depending on your environment the error might differ. It is important to notice that HTML is being received instead of JSON and this could indicate something is blocking the request (WAF, Proxy etc.)
Overview of possible solutions
Solution:
Contact your Firewall/WAF team with the error message found in the HAR file
Your request was rejected. Please contact Servicedesk, quoting <reference-number> and request ID: <id-of-the-issue>
and ask them to unblock you.
Outcome
Once your Firewall/WAF team has confirmed the issue is fixed, you can try again to add the variable to the workspace and it should work fine.