apigee / apigeelint

Static code analysis for Apigee proxy bundles to encourage API developers to use best practices and avoid anti-patterns.
Apache License 2.0
92 stars 71 forks source link

EP002 triggers wrongly on "Misplaced 'Condition' element child of DefaultFaultRule" #365

Closed karsten-wagner closed 1 year ago

karsten-wagner commented 1 year ago

I am configuring a DefaultFaultRule as follows:

<DefaultFaultRule name="DefaultFaultRule">
  <Condition>flow.custom_error_text NotEquals null</Condition>
  <AlwaysEnforce>true</AlwaysEnforce>
  <Step>
    <Name>AssignMessage-ErrorHandler-1</Name>
  </Step>
  <Step>
    <Name>AssignMessage-ErrorHandler-2</Name>
  </Step>
</DefaultFaultRule>

This seems to work well to execute the whole block only in case the condition is true.

The Apigee documentation also indicates placing a condition for the whole DefaultFaultRule is supported:

A \<DefaultFaultRule> can also have a \\

See: https://docs.apigee.com/api-platform/fundamentals/fault-handling#simplefaulthandlingexample-2createthefaultrulethatwilltriggerthepolicy

When I execute apigeelint in v2.36.0, the linter triggers rule EP002 with the following text in the report:

Misplaced 'Condition' element child of DefaultFaultRule

I believe this is wrong behavior and should gracefully ignore the condition statement within a DefaultFaultRule code block.

ssvaidyanathan commented 1 year ago

Fixed in v2.37.0 Please test and confirm

karsten-wagner commented 1 year ago

@ssvaidyanathan, yes, it works. Thanks for the fix!