Creating a policy via API call is saved on the filesystem without a filename

Hi,

I am using Tyk-OSS 5.4.0 and I was able to create a policy via API call (endpoint: /policies):

I got the following response from the API:

{
  "key": "",
  "status": "ok",
  "action": "added"
}

However when inspecting the policies directory I took notice that the policy file was created without a name but only with the file extension : .json :

Should the API not generate a filename automatically likewise I can seen on this post: #5567

evel=error msg="Failed to create file! - open ZGVmYXVsdC9odHRwYmlu.json: read-only file system"

My Helm Configuration:

    extraEnvs:
       - name: TYK_LOGLEVEL
         value: "debug"
       - name: TYK_GW_POLICIES_POLICYSOURCE
         value: ""
       - name: TYK_GW_POLICIES_POLICYRECORDNAME
         value: ""
       - name: TYK_GW_POLICIES_POLICYPATH
         value: "/opt/tyk-gateway/policies"

    extraVolumes:
        - name: tyk-policies-volume

    extraVolumeMounts:
        - name: tyk-policies-volume
          mountPath: /opt/tyk-gateway/policies
          readOnly: false

Thank you!

Yes I have run into this. We have an internal ticket open for this to validate empty policy names. So in the meantime, try supplying a name for the policy and avoid empty names.

Thanks for the answer. The name was given:

{
    "access_rights": {
      "<API ID>": {
        "api_name": "<API NAME>",
        "api_id": "<API ID>",
        "versions": [
          "Default"
        ]
      }
    },
    "name" : "jwt_policy",
    "active": true
}

I see. My bad.
It’s the ID you are suggesting. It looks like it’s required from the source

You could open a Github Issue for this