problem with the VerifyAPIKey policy: "Illegal repetition" error occurs

I have defined a policy type Verify API Key in the REQUEST flow of Preflow in default in "Proxy Endpoints", whose code is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<VerifyAPIKey async="false" continueOnError="false" enabled="true" name="VerifyClientAPIKey">

<DisplayName>VerifyClientAPIKey</DisplayName>

<APIKey ref="request.header.apikey"/>

</VerifyAPIKey>

But when I try the proxy call the following error occurs (with Response Code = 400):

{

"fault": {

"faultstring": "Illegal repetition near index 14\n/request/[^/]+/{request_id}\n ^",

"detail": {

"errorcode": "Bad Request"

}

}

}

I assume that the error occurs for some reason due to the VerifyAPIKey policy, because when its enabled property is assigned the value "false" the error does not occur and the proxy gives me the answer with Status "200 OK", but there is no validation of "Api Key" and I need to implement this validation. Also, if I remove the policy from the REQUEST flow of Preflow in default in "Proxy Endpoints", in such a way that "Attached to" is assigned "Not used in any flows", the error also does not occur (the proxy responds satisfactorily )

I think I should mention that in addition to the VerifyAPIKey policy, I have a policy called "CORSResponse" which is of type AssignMessage and whose code is as I show it below, but when I disable it (enabled = "false") the proxy response does not I see that it is affected in nothing (the Response Code is 200), which raises doubts about its function:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<AssignMessage async="false" continueOnError="false" enabled="true" name="CORSResponse">

<DisplayName>CORSResponse</DisplayName>

<FaultRules/>

<Properties/>

<Set>

<Headers>

<Header name="Access-Control-Allow-Headers">Origin, X-Requested-With, Content-Type, Accept, Authorization, apikey</Header>

<Header name="Access-Control-Max-Age">3628800</Header>

<Header name="Access-Control-Allow-Methods">GET, PUT, POST, DELETE, OPTION, OPTIONS</Header>

<Header name="Access-Control-Allow-Origin">https://<dominio_accedido></Header>

</Headers>

</Set>

<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

<AssignTo createNew="false" transport="http" type="response"/>

</AssignMessage>

--

The question is: ¿why do I get the error message “…"faultstring": "Illegal repetition near index 14\n/request/[^/]+/{request_id}\n ^"…”?

Solved Solved
0 2 234
1 ACCEPTED SOLUTION

I think maybe there is a pattern like

/request/[^/]+/{request_id}

in one of your conditions, or one of your policies (like ExtractVariables, etc).

And that is what is causing the error.

I do not think the error is coming from VerifyApiKey.

View solution in original post

2 REPLIES 2

I think maybe there is a pattern like

/request/[^/]+/{request_id}

in one of your conditions, or one of your policies (like ExtractVariables, etc).

And that is what is causing the error.

I do not think the error is coming from VerifyApiKey.

Thank you. It was what you said. I have already overcome the situation. Well, I have not had more policies but only the 2 that I mentioned, therefore the pattern "/ request / [^ /] + / {request_id}" was not in any policy; but I found it in one of several Product Paths and in several resources within default in "Proxy Endpoints". I removed, for the time being, these elements, and it worked for me.