ApigeeLint:An appropriate check for a message body was not found on the enclosing Step or Flow:PO004

I am running my proxy through a CI/CD pipeline. It fails at Apigee Lint stage with this error>

What could be the issue

 

brianademba_0-1646221273351.png

This is the Flow:

 

 

 

 <Flow name="QueryStatus">
            <Description/>
            <Request>
                <Step>
                    <Condition>(request.content != null)</Condition>
                    <FaultRules/>
                    <Name>EV-QueryStatus</Name>
                </Step>
                <Step>
                    <FaultRules/>
                    <Name>JS-QueryStatus</Name>
                </Step>
                <Step>
                    <Name>AM-RemoveApikey</Name>
                </Step>
            </Request>
            <Response>
                <Step>
                    <Condition>(response.content != null)</Condition>
                    <FaultRules/>
                    <Name>EV-QueryResponse</Name>
                </Step>
                <Step>
                    <FaultRules/>
                    <Name>AM-QueryResponse</Name>
                </Step>
            </Response>
            <Condition>(proxy.pathsuffix MatchesPath "/user/request/**") and (request.verb = "GET")</Condition>
        </Flow>

 

 

JS-QueryStatus.js

var pathSuffix = context.getVariable("proxy.pathsuffix");
var referenceNumber= context.getVariable('referenceNumber');
var queryStatusBasepath= context.getVariable('queryStatusBasepath');
print(referenceNumber);
if (pathSuffix ="/charge/request"+"/"+referenceNumber){
    var queryTargetPath = queryStatusBasepath+"/"+referenceNumber;
    context.setVariable ('queryTargetPath',queryTargetPath);}
0 14 1,200
14 REPLIES 14

It's hard to tell from the image snip you provided, but I think that error PO004 pertains to the ExtractVariables policy that precedes the JS policy. Can you send ALL the output of the apigeelint tool?

PO004 aims to check for a condition that applies to an ExtractVariables. It checks that there is a Condition, and that the Condition examines the content within the message that you use as Source in the ExtractVariables.  If you have a Condition that checks request.content, then the PO004 plugin will not generate a warning if you use request as the Source. 

What does your ExtractVariables policy, EV-QueryStatus look like? Given the input you've shown, if it extracts from an XMLPayload and references request as the Source, then I would not expect an error. If it extracts from an XMLPayload and references a Source which is not request, then I would expect the error you saw.

An example that I would expect to not generate the error: 

 

<ExtractVariables name="EV-QueryStatus">
   <Source>request</Source>
   <XMLPayload>
     <Variable name='targetLocation' type='string'>
       <XPath>/config/target/text()</XPath>
     </Variable>
   </XMLPayload>
   <VariablePrefix>extracted</VariablePrefix>
</ExtractVariables>

 

An example that I would expect to generate an error:

 

<ExtractVariables name="EV-QueryStatus">
   <Source>response</Source> <!-- not request ! -->
   <XMLPayload>
     <Variable name='targetLocation' type='string'>
       <XPath>/config/target/text()</XPath>
     </Variable>
   </XMLPayload>
   <VariablePrefix>extracted</VariablePrefix>
</ExtractVariables>

 

 

Also, what version of apigeelint are you running? There have been some recent changes to the PO004 plugin, specifically correcting the pattern it uses to test the condition for the ExtractVariables Step.   Using the latest version of apigeelint, which is v2.21.0, I tested something similar to what you have, and it worked as expected. It allowed the condition you specified on the EV-QueryStatus Step.

You can find the version of your installed apigeelint like this:

 

 

# if you have installed apigeelint globally
apigeelint --version

# or, from the apigeelint folder
node ./cli.js --version

 

 

Output from Apigee lint

brianademba_0-1646288031709.png

I am running v 2.10.0 of Apigee lint

EV-QueryStatus policy:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="EV-QueryStatus">
    <DisplayName>EV-QueryStatus</DisplayName>
    <FaultRules/>
    <Properties/>
    <URIPath>
        <Pattern ignoreCase="true">**/charge/request/{referenceNumber}</Pattern>
    </URIPath>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <Source clearPayload="false">request</Source>
</ExtractVariables>

 

 

EV-Attributes

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="EV-Attributes">
    <DisplayName>EV-Attributes</DisplayName>
    <Properties/>
    <Source>AccessEntity.AE-ApiKey</Source>
    <VariablePrefix>developer</VariablePrefix>
    <XMLPayload>
        <Variable name="developerEmail" type="string">
            <XPath>/Developer/Email</XPath>
        </Variable>
        <Variable name="developerId" type="string">
            <XPath>/Developer/DeveloperId</XPath>
        </Variable>
        <Variable name="appId" type="string">
            <XPath>/App.AppId</XPath>
        </Variable>
    </XMLPayload>
</ExtractVariables>

Thanks for the additional information. 

As I said, there have been some changes in the PO004 plugin recently. What version of apigeelint are you using? Can you try with the latest version? 

Reading your output, It's not the EV-QueryStatus that is causing the error. It's EV-Attributes. That shouldn't happen with the latest version. Please try and see. Let me know. 

did you try it out?  What did you determine?

Updating apigeelint to the latest version did not solve the issue. 

Hi Brian, 

Can you open an issue on the apigeelint repo?  Please include

  • the output of apigeelint --version
  • the specific command you ran to invoke apigeelint
  • a clear description of the problem you are seeing
  • a minimal apiproxy that reproduces the problematic behavior you're seeing

We'll take a look.

Hi @dchiesa1 ,

I am trying to deploy the soap api proxy but getting lint error

majjiku_0-1689857785075.png

Could you please help us to resolve the issue.

Thanks,

M Kumari.

Hello @majjiku ,

You need to add a condition to the EV step to eliminate the error

 

<Step>
<Condition>(request.content != null)</Condition>
<Name>MED-EV-Extractdata</Name>
</Step>

 

Hi @brianademba ,

Thanks for the response but still getting lint error.

Yes, I already added that condition but still majjiku_0-1689861144138.png

 

 

What version of Apigee lint are you running? Seems there are changes in the lastest Apigee lint release (>v2.31.0). 

 PO001, PO002, PO003, PO004, and PO005 have been converted to ST006, ST007, ST003, ST004, and ST005, respectively. These plugins move from the "Policy" category to the "Step" category because the plugin analyzes the attachment of the policy in a Step element, rather than the policy itself. Also these plugins will now generate warnings, rather than errors.

But same apigeelint working for all rest APIs .only for one soap api it's failing. And this is our first soap api and we are facing lint issue for extract variable policy

What version of Apigee lint are you running? 

Hi,

It's working after adding a condition in extract data earlier also it is there but it's defined as string.

Request content type != "null"

Thanks @dchiesa1 @brianademba

ok. Glad to hear it. 

One final note: You may want to check and update the version of apigeelint.  The current version is 2.39.0