You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: In the TOML configurations we have enabled the analytics with the [apim.analytics].
In the APIM 4.0.0 latest U2 level 322, we are trying to customize the 404 error by editing the default sequence called “resource_mismatch_handler.xml”.
After adding the above highlighted configurations, we got the following error with the correct customized response.
[2024-11-27 11:10:48,361] INFO - LogMediator {api:PizzaShackAPI:v1.0.0} STATUS = Executing default 'fault' sequence, ERROR_CODE = 900906, ERROR_MESSAGE = TEST
[2024-11-27 11:10:48,369] ERROR - AnalyticsMetricsHandler Error Occurred when collecting data
java.lang.NullPointerException: null
at org.wso2.carbon.apimgt.common.analytics.collectors.impl.fault.AbstractFaultDataCollector.processRequest(AbstractFaultDataCollector.java:53) ~[org.wso2.carbon.apimgt.common.analytics_9.0.174.197.jar:?]
at org.wso2.carbon.apimgt.common.analytics.collectors.impl.fault.AuthFaultDataCollector.collectFaultData(AuthFaultDataCollector.java:51) ~[org.wso2.carbon.apimgt.common.analytics_9.0.174.197.jar:?]
at org.wso2.carbon.apimgt.common.analytics.collectors.impl.FaultyRequestDataCollector.collectData(FaultyRequestDataCollector.java:63) ~[org.wso2.carbon.apimgt.common.analytics_9.0.174.197.jar:?]
at org.wso2.carbon.apimgt.common.analytics.collectors.impl.GenericRequestDataCollector.collectData(GenericRequestDataCollector.java:49) ~[org.wso2.carbon.apimgt.common.analytics_9.0.174.197.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.analytics.AnalyticsMetricsHandler.handleResponseOutFlow_aroundBody8(AnalyticsMetricsHandler.java:110) [org.wso2.carbon.apimgt.gateway_9.0.174.463.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.analytics.AnalyticsMetricsHandler.handleResponseOutFlow(AnalyticsMetricsHandler.java:81) [org.wso2.carbon.apimgt.gateway_9.0.174.463.jar:?]
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:187) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:569) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:120) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:214) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler.onResourceNotFoundError_aroundBody20(CORSRequestHandler.java:284) [org.wso2.carbon.apimgt.gateway_9.0.174.463.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler.onResourceNotFoundError(CORSRequestHandler.java:278) [org.wso2.carbon.apimgt.gateway_9.0.174.463.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler.handleResourceNotFound_aroundBody18(CORSRequestHandler.java:274) [org.wso2.carbon.apimgt.gateway_9.0.174.463.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler.handleResourceNotFound(CORSRequestHandler.java:258) [org.wso2.carbon.apimgt.gateway_9.0.174.463.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler.handleRequest_aroundBody8(CORSRequestHandler.java:174) [org.wso2.carbon.apimgt.gateway_9.0.174.463.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler.handleRequest(CORSRequestHandler.java:124) [org.wso2.carbon.apimgt.gateway_9.0.174.463.jar:?]
at org.apache.synapse.api.API.process(API.java:389) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.api.AbstractApiHandler.apiProcessNonDefaultStrategy(AbstractApiHandler.java:109) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.api.AbstractApiHandler.identifyAPI(AbstractApiHandler.java:129) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.api.AbstractApiHandler.dispatchToAPI(AbstractApiHandler.java:61) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.api.rest.RestRequestHandler.dispatchToAPI(RestRequestHandler.java:84) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.api.rest.RestRequestHandler.process(RestRequestHandler.java:70) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:54) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:344) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:101) [synapse-core_2.1.7.wso2v227_89.jar:2.1.7-wso2v227.89]
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) [axis2_1.6.1.wso2v63_8.jar:?]
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:395) [synapse-nhttp-transport_2.1.7.wso2v227_81.jar:?]
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:209) [synapse-nhttp-transport_2.1.7.wso2v227_81.jar:?]
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) [axis2_1.6.1.wso2v63_8.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
Observations of Debugging
The NullPointerException occurs at the line referenced in [1]. Upon debugging, the root cause of this issue was identified as follows:
The error code 900906 corresponds to "No matching resource found in the API for the given request" ([2]). When the fault sequence is executed with this error code, the SynapseAnalyticsDataProvider interprets it as an Authentication Fault Request ([3]).
However, during the execution of the getFaultSubCategory method ([4]) in the SynapseAnalyticsDataProvider, the fault subcategory is determined using a switch statement. Unfortunately, the switch cases do not include a specific case to return a subcategory for the 900906 error code. This results in the sub-category of the fault as OTHER.
After this logic, when AsbtractFaultDataCollector check whether this sub category is valid or not via the method isValidSubCategory, it checks whether this subCategory as an instance of the FaultSubCategories.Authentication as below. This returns false and this results in throwing the InvalidCategoryException[5].
Description
Hi Team,
Reproducing Steps and Summary of the issue
Note: In the TOML configurations we have enabled the analytics with the
[apim.analytics]
.In the APIM 4.0.0 latest U2 level 322, we are trying to customize the 404 error by editing the default sequence called “resource_mismatch_handler.xml”.
After adding the above highlighted configurations, we got the following error with the correct customized response.
Observations of Debugging
The
NullPointerException
occurs at the line referenced in [1]. Upon debugging, the root cause of this issue was identified as follows:The error code
900906
corresponds to "No matching resource found in the API for the given request" ([2]). When the fault sequence is executed with this error code, theSynapseAnalyticsDataProvider
interprets it as an Authentication Fault Request ([3]).However, during the execution of the
getFaultSubCategory
method ([4]) in theSynapseAnalyticsDataProvider
, the fault subcategory is determined using a switch statement. Unfortunately, the switch cases do not include a specific case to return a subcategory for the900906
error code. This results in the sub-category of the fault as OTHER.After this logic, when
AsbtractFaultDataCollector
check whether this sub category is valid or not via the methodisValidSubCategory
, it checks whether this subCategory as an instance of theFaultSubCategories.Authentication
as below. This returns false and this results in throwing theInvalidCategoryException
[5].[1] - https://github.com/wso2/carbon-apimgt/blob/87f50542eaf2572f044b24d0888beda90f38b046/components/apimgt/org.wso2.carbon.apimgt.common.analytics/src/main/java/org/wso2/carbon/apimgt/common/analytics/collectors/impl/fault/AbstractFaultDataCollector.java#L53
[2] - https://apim.docs.wso2.com/en/4.0.0/troubleshooting/error-handling/#:~:text=application%20user%20tokens-,900906,-No%20matching%20resource
[3] - https://github.com/wso2/carbon-apimgt/blob/8eeb6fbd0e4740ab9418fa5ed40acdec8e19efb5/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/analytics/SynapseAnalyticsDataProvider.java#L367
[4] - https://github.com/wso2/carbon-apimgt/blob/87f50542eaf2572f044b24d0888beda90f38b046/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/analytics/FaultCodeClassifier.java#L45
[5] - https://github.com/wso2/carbon-apimgt/blob/87f50542eaf2572f044b24d0888beda90f38b046/components/apimgt/org.wso2.carbon.apimgt.common.analytics/src/main/java/org/wso2/carbon/apimgt/common/analytics/collectors/impl/fault/AbstractFaultDataCollector.java#L53
Thanks & Regards,
Shavindu S.
Steps to Reproduce
Mentioned above
Version
APIM 4.0.0
Environment Details (with versions)
No response
The text was updated successfully, but these errors were encountered: