PreFlow multiple conditions not exiting after match

I have following steps in my PreFlow. Problem is all steps are being executed every single time even if the condition in step 1 is met. What could be the problem.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>Oauth2-V2-VerifyAccessToken-CustomerScope</Name>
<Condition>proxy.pathsuffix MatchesPath "/xml" AND request.verb = "GET"</Condition>
</Step>
</Request>
<Request>
<Step>
<Name>Oauth2-V2-VerifyAccessToken-AdminScope</Name>
<Condition>proxy.pathsuffix MatchesPath "/json" AND request.verb = "GET"</Condition>
</Step>
</Request>
<Request>
<Step>
<Name>Oauth2-V2-VerifyAccessToken-GuestScope</Name>
<Condition>proxy.pathsuffix MatchesPath "/user" AND request.verb = "GET"</Condition>
</Step>
</Request>
<Response/>
</PreFlow>
<Flows/>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<HTTPProxyConnection>

Solved Solved
0 1 75
1 ACCEPTED SOLUTION

Your config seems to include multiple Request elements. That's wrong.  I don't know what behavior would result from that configuration. It's a failure of the Apigee config validator, a bug, that it does not tell you this. 

 

<ProxyEndpoint name="default">
  <PreFlow name="PreFlow">
    <Request> <!-- Request element #1 -->
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-CustomerScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/xml" AND request.verb = "GET"</Condition>
      </Step>
    </Request>
    <Request> <!-- Request element #2 (WRONG - there should be only one) -->
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-AdminScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/json" AND request.verb = "GET"</Condition>
      </Step>
    </Request>
    <Request> <!-- Request element #3 (WRONG) -->
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-GuestScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/user" AND request.verb = "GET"</Condition>
      </Step>
    </Request>
    <Response/>
  </PreFlow>
  <Flows/>
  <PostFlow name="PostFlow">
    <Request/>
    <Response/>
  </PostFlow>
  ...

 

You should have exactly one Request element.

 

<ProxyEndpoint name="default">
  <PreFlow name="PreFlow">
    <Request> 
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-CustomerScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/xml" AND request.verb = "GET"</Condition>
      </Step>
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-AdminScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/json" AND request.verb = "GET"</Condition>
      </Step>
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-GuestScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/user" AND request.verb = "GET"</Condition>
      </Step>
    </Request>
    <Response/>
  </PreFlow>
  <Flows/>
  <PostFlow name="PostFlow">
    <Request/>
    <Response/>
  </PostFlow>
  ...

 

 ps: if you ran your proxy through apigeelint, it would have told you about the extraneous Request elements! 

 

View solution in original post

1 REPLY 1

Your config seems to include multiple Request elements. That's wrong.  I don't know what behavior would result from that configuration. It's a failure of the Apigee config validator, a bug, that it does not tell you this. 

 

<ProxyEndpoint name="default">
  <PreFlow name="PreFlow">
    <Request> <!-- Request element #1 -->
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-CustomerScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/xml" AND request.verb = "GET"</Condition>
      </Step>
    </Request>
    <Request> <!-- Request element #2 (WRONG - there should be only one) -->
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-AdminScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/json" AND request.verb = "GET"</Condition>
      </Step>
    </Request>
    <Request> <!-- Request element #3 (WRONG) -->
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-GuestScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/user" AND request.verb = "GET"</Condition>
      </Step>
    </Request>
    <Response/>
  </PreFlow>
  <Flows/>
  <PostFlow name="PostFlow">
    <Request/>
    <Response/>
  </PostFlow>
  ...

 

You should have exactly one Request element.

 

<ProxyEndpoint name="default">
  <PreFlow name="PreFlow">
    <Request> 
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-CustomerScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/xml" AND request.verb = "GET"</Condition>
      </Step>
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-AdminScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/json" AND request.verb = "GET"</Condition>
      </Step>
      <Step>
        <Name>Oauth2-V2-VerifyAccessToken-GuestScope</Name>
        <Condition>proxy.pathsuffix MatchesPath "/user" AND request.verb = "GET"</Condition>
      </Step>
    </Request>
    <Response/>
  </PreFlow>
  <Flows/>
  <PostFlow name="PostFlow">
    <Request/>
    <Response/>
  </PostFlow>
  ...

 

 ps: if you ran your proxy through apigeelint, it would have told you about the extraneous Request elements!