Azure / azure-libraries-for-java

Azure Management Libraries for Java
https://docs.microsoft.com/en-us/java/azure/
MIT License
94 stars 98 forks source link

[BUG] exception when updating application gateway v2 waf_v2 #1349

Closed weidongxu-microsoft closed 3 years ago

weidongxu-microsoft commented 3 years ago

Java SDK 1.35 ( I can repo also with 1.38.1)

If I have a application gateway v2 sku waf_v2 with exclusion setup at WAF level

And run backend update

            ApplicationGateway appGateway = azure.applicationGateways().getByResourceGroup(rgName, appGwName);                     
            final ApplicationGateway refreshedAppGateway = appGateway.refresh();            
            refreshedAppGateway.update()
                    .updateBackend(applicationGatewayBackend)
                    .withIPAddress("192.168.229.6")
                    .parent()
                    .apply();

Error:

webApplicationFirewallConfiguration.exclusions.selectorMatchOperator is required and cannot be null.
java.lang.IllegalArgumentException: webApplicationFirewallConfiguration.exclusions.selectorMatchOperator is required and cannot be null.
        at com.microsoft.rest.Validator.validateClass(Validator.java:134)
        at com.microsoft.rest.Validator.validate(Validator.java:80)
        at com.microsoft.azure.management.network.implementation.ApplicationGatewaysInner.createOrUpdateWithServiceResponseAsync(ApplicationGatewaysInner.java:485)
        at com.microsoft.azure.management.network.implementation.ApplicationGatewaysInner.createOrUpdateAsync(ApplicationGatewaysInner.java:455)
        at com.microsoft.azure.management.network.implementation.ApplicationGatewayImpl$4.call(ApplicationGatewayImpl.java:563)
        at com.microsoft.azure.management.network.implementation.ApplicationGatewayImpl$4.call(ApplicationGatewayImpl.java:560)
        at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
        at rx.internal.producers.SingleProducer.request(SingleProducer.java:65)
        at rx.Subscriber.setProducer(Subscriber.java:211)
        at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
        at rx.internal.operators.OperatorSingle$ParentSubscriber.onCompleted(OperatorSingle.java:110)
        at rx.internal.operators.DeferredScalarSubscriber.complete(DeferredScalarSubscriber.java:102)
        at rx.internal.operators.OnSubscribeTakeLastOne$TakeLastOneSubscriber.onCompleted(OnSubscribeTakeLastOne.java:57)     
        at rx.internal.operators.OnSubscribeSwitchIfEmpty$AlternateSubscriber.onCompleted(OnSubscribeSwitchIfEmpty.java:143)  
        at rx.internal.util.ScalarSynchronousObservable$WeakSingleProducer.request(ScalarSynchronousObservable.java:285)      
        at rx.internal.producers.ProducerArbiter.setProducer(ProducerArbiter.java:126)
        at rx.internal.operators.OnSubscribeSwitchIfEmpty$AlternateSubscriber.setProducer(OnSubscribeSwitchIfEmpty.java:138)  
        at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:138)
        at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:129)
        at rx.Observable.unsafeSubscribe(Observable.java:10327)
        at rx.internal.operators.OnSubscribeSwitchIfEmpty$ParentSubscriber.subscribe(OnSubscribeSwitchIfEmpty.java:101)       
        at rx.internal.operators.OnSubscribeSwitchIfEmpty.call(OnSubscribeSwitchIfEmpty.java:52)
        at rx.internal.operators.OnSubscribeSwitchIfEmpty.call(OnSubscribeSwitchIfEmpty.java:31)
        at rx.Observable.unsafeSubscribe(Observable.java:10327)
        at rx.internal.operators.DeferredScalarSubscriber.subscribeTo(DeferredScalarSubscriber.java:153)
        at rx.internal.operators.OnSubscribeTakeLastOne.call(OnSubscribeTakeLastOne.java:32)
        at rx.internal.operators.OnSubscribeTakeLastOne.call(OnSubscribeTakeLastOne.java:22)
        at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
        at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
        at rx.Observable.unsafeSubscribe(Observable.java:10327)
        at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
        at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
        at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
        at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
        at rx.Observable.unsafeSubscribe(Observable.java:10327)
        at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
        at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
        at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
        at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
        at rx.Observable.unsafeSubscribe(Observable.java:10327)
        at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.call(OperatorSubscribeOn.java:100)
        at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:230)
        at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
ovidiu10 commented 3 years ago

thanks @weidongxu-microsoft and @xccc-msft working to make another repo

ovidiu10 commented 3 years ago

the key issue is RequestHeaderNames with header "Referer" https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer

.withExclusions(Arrays.asList(new ApplicationGatewayFirewallExclusion().withSelector("Referer")
                            .withMatchVariable("Equals").withMatchVariable("RequestHeaderNames"))))

image

I got same error even if I try to create the application gateway

webApplicationFirewallConfiguration.exclusions.selectorMatchOperator is required and cannot be null. java.lang.IllegalArgumentException: webApplicationFirewallConfiguration.exclusions.selectorMatchOperator is required and cannot be null

xseeseesee commented 3 years ago

After investigation, the swagger definition of ApplicationGatewayFirewallExclusion shows all properties are required here while the server only returns matchVariable if the exclusion rule is with Equals any and *. Add Service Attention so the service team could help check if they should update swagger or add missing properties in the response.

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @surajmb, @appgwsuppgithub.

Issue Details
Java SDK 1.35 ( I can repo also with 1.38.1) If I have a application gateway v2 sku waf_v2 with exclusion setup at WAF level And run backend update ``` ApplicationGateway appGateway = azure.applicationGateways().getByResourceGroup(rgName, appGwName); final ApplicationGateway refreshedAppGateway = appGateway.refresh(); refreshedAppGateway.update() .updateBackend(applicationGatewayBackend) .withIPAddress("192.168.229.6") .parent() .apply(); ``` Error: ``` webApplicationFirewallConfiguration.exclusions.selectorMatchOperator is required and cannot be null. java.lang.IllegalArgumentException: webApplicationFirewallConfiguration.exclusions.selectorMatchOperator is required and cannot be null. at com.microsoft.rest.Validator.validateClass(Validator.java:134) at com.microsoft.rest.Validator.validate(Validator.java:80) at com.microsoft.azure.management.network.implementation.ApplicationGatewaysInner.createOrUpdateWithServiceResponseAsync(ApplicationGatewaysInner.java:485) at com.microsoft.azure.management.network.implementation.ApplicationGatewaysInner.createOrUpdateAsync(ApplicationGatewaysInner.java:455) at com.microsoft.azure.management.network.implementation.ApplicationGatewayImpl$4.call(ApplicationGatewayImpl.java:563) at com.microsoft.azure.management.network.implementation.ApplicationGatewayImpl$4.call(ApplicationGatewayImpl.java:560) at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69) at rx.internal.producers.SingleProducer.request(SingleProducer.java:65) at rx.Subscriber.setProducer(Subscriber.java:211) at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102) at rx.internal.operators.OperatorSingle$ParentSubscriber.onCompleted(OperatorSingle.java:110) at rx.internal.operators.DeferredScalarSubscriber.complete(DeferredScalarSubscriber.java:102) at rx.internal.operators.OnSubscribeTakeLastOne$TakeLastOneSubscriber.onCompleted(OnSubscribeTakeLastOne.java:57) at rx.internal.operators.OnSubscribeSwitchIfEmpty$AlternateSubscriber.onCompleted(OnSubscribeSwitchIfEmpty.java:143) at rx.internal.util.ScalarSynchronousObservable$WeakSingleProducer.request(ScalarSynchronousObservable.java:285) at rx.internal.producers.ProducerArbiter.setProducer(ProducerArbiter.java:126) at rx.internal.operators.OnSubscribeSwitchIfEmpty$AlternateSubscriber.setProducer(OnSubscribeSwitchIfEmpty.java:138) at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:138) at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:129) at rx.Observable.unsafeSubscribe(Observable.java:10327) at rx.internal.operators.OnSubscribeSwitchIfEmpty$ParentSubscriber.subscribe(OnSubscribeSwitchIfEmpty.java:101) at rx.internal.operators.OnSubscribeSwitchIfEmpty.call(OnSubscribeSwitchIfEmpty.java:52) at rx.internal.operators.OnSubscribeSwitchIfEmpty.call(OnSubscribeSwitchIfEmpty.java:31) at rx.Observable.unsafeSubscribe(Observable.java:10327) at rx.internal.operators.DeferredScalarSubscriber.subscribeTo(DeferredScalarSubscriber.java:153) at rx.internal.operators.OnSubscribeTakeLastOne.call(OnSubscribeTakeLastOne.java:32) at rx.internal.operators.OnSubscribeTakeLastOne.call(OnSubscribeTakeLastOne.java:22) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10327) at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48) at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10327) at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48) at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.unsafeSubscribe(Observable.java:10327) at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.call(OperatorSubscribeOn.java:100) at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:230) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ```
Author: weidongxu-microsoft
Assignees: xccc-msft
Labels: `Mgmt`, `Network - Application Gateway`, `Service Attention`
Milestone: -