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

DXE-4473 Error exporting property. Saving terraform files. Executing template: rules_v2024-10-21. Range can't iterate over #82

Open
glenthomas opened this issue Dec 10, 2024 · 9 comments

Comments

@glenthomas
Copy link

glenthomas commented Dec 10, 2024

I have a bug with the export-property command when exporting rule format 2024-10-21.

The output is:

Fetching property www.something.com [OK]
Fetching group  [OK]
Fetching property version  [OK]
Fetching property rules  [OK]
Fetching product name  [OK]
Fetching hostnames  [OK]
Fetching activation details  [OK]
Saving TF configurations  [FAIL]
Error exporting property: saving terraform project files: executing template: rules_v2024-10-21.tmpl: 
template: rules_v2024-10-21.tmpl:9347:20: executing "queryStringParameter" at <$v>: 
range can't iterate over api.blah.something.com

I have some match criteria that uses an array of strings for match values. This is from the downloaded rules JSON:

"criteria": [
    {
        "name": "queryStringParameter",
        "options": {
            "parameterName": "host",
            "matchOperator": "IS_ONE_OF",
            "values": "api.blah.something.com",
            "matchWildcardName": false,
            "matchCaseSensitiveName": true,
            "matchWildcardValue": false,
            "matchCaseSensitiveValue": true,
            "escapeValue": false
        }
    }
],

Strangely, I have similar blocks of JSON in the export that have a single array item, but include it as an array of strings rather than just a string:

"criteria": [
    {
        "name": "queryStringParameter",
        "options": {
            "parameterName": "host",
            "matchOperator": "IS_ONE_OF",
            "values": [
                "api.blah.something.com",
            ],
            "matchWildcardName": false,
            "matchCaseSensitiveName": true,
            "matchWildcardValue": false,
            "matchCaseSensitiveValue": true,
            "escapeValue": false
        }
    }
],
@lsadlon lsadlon changed the title Error exporting property. Saving terraform files. Executing template: rules_v2024-10-21. Range can't iterate over DXE-4473 Error exporting property. Saving terraform files. Executing template: rules_v2024-10-21. Range can't iterate over Dec 10, 2024
@lsadlon
Copy link

lsadlon commented Dec 10, 2024

Hi @glenthomas

I was able to reproduce it. We will inform you about progress.

BR,
Lukasz

@glenthomas
Copy link
Author

glenthomas commented Dec 11, 2024

Hello @lsadlon, please let me know if there are any suitable workarounds as I would like to continue with my work ASAP. Thanks.

@lsadlon
Copy link

lsadlon commented Dec 11, 2024

Hi @glenthomas,

You can open your property in UI and save it there even without any changes. It should covert this problematic element to array of strings.

BR,
Lukasz

@glenthomas
Copy link
Author

Hello @lsadlon, to confirm, are you saying that I can:

  1. Edit a new version of the property in the Control Center.
  2. Save the version without any changes.
  3. Export using cli-terraform

and it will now work? So somebody has fixed the values attribute so that it is always a list of strings?

@glenthomas
Copy link
Author

...I have just tried this and am still getting the same error.

@lsadlon
Copy link

lsadlon commented Dec 12, 2024

Hi @glenthomas,

So problem is that cli-terraform while exporting data expect values attribute to be list of strings. Other way you can fix it is using API (e.g. Postman) https://techdocs.akamai.com/property-mgr/reference/put-property-version-rules and update your rules accordingly.

BR,
Lukasz

@glenthomas
Copy link
Author

I have downloaded the rules from the property as JSON. I have corrected the schema to use an array of strings and am now trying to PUT the rules back via Postman. I am getting this generic error:

{
    "type": "https://problems.luna.akamaiapis.net/papi/v0/http/bad-request",
    "title": "Bad Request",
    "detail": "The system cannot understand your request.  Please check the syntax and correct any problems.",
    "instance": "https://{redacted}.luna.akamaiapis.net/papi/v1/properties/123456/versions/1234/rules#d1b1675ae15852fa",
    "status": 400
}

How can I validate the rules JSON? I have tried using params validateRules=true and validateMode=full and still get the same error response.

@glenthomas
Copy link
Author

I have also tried the rules PATCH endpoint and am getting the same error response

Request:

[
  {
    "op": "replace",
    "path": "/rules/children/117/children/0/children/0/criteria/0/values",
    "value": ["api.blah.something.com"]
  }
]

Response:

{
    "type": "https://problems.luna.akamaiapis.net/papi/v0/http/bad-request",
    "title": "Bad Request",
    "detail": "The system cannot understand your request.  Please check the syntax and correct any problems.",
    "instance": "https://{redacted}.luna.akamaiapis.net/papi/v1/properties/123456/versions/1234/rules#d1b1675ae15852fa",
    "status": 400
}

@lsadlon
Copy link

lsadlon commented Dec 13, 2024

Hi @glenthomas,

To be honest from error message that you get I cannot tell you what is wrong, but it looks there is something wrong with request itself, rather than rules.

BR,
Lukasz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants