wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
846 stars 785 forks source link

Api invocation fails for an api which has a /t URI pattern for a resource in Super tenant #7841

Closed TanyaM closed 6 days ago

TanyaM commented 4 years ago

Description:

If an API has a resource as /t/something as a URI pattern for a resource, then the API invocation fails with the below error. [2020-03-27 17:47:52,237] ERROR - ServerWorker Error processing GET request for : /foo/1.2.3/bar/t/test. java.lang.IllegalStateException: Tenant ID cannot be -1 at org.wso2.carbon.caching.impl.CarbonCacheManager.<init>(CarbonCacheManager.java:65) ~[javax.cache.wso2_4.6.0.jar:?] at org.wso2.carbon.caching.impl.CacheManagerFactoryImpl.getCacheManager(CacheManagerFactoryImpl.java:94) ~[javax.cache.wso2_4.6.0.jar:?] at javax.cache.Caching.getCacheManager(Caching.java:101) ~[javax.cache.wso2_4.6.0.jar:?] at org.wso2.carbon.apimgt.impl.utils.APIUtil.getCache_aroundBody566(APIUtil.java:8454) ~[org.wso2.carbon.apimgt.impl_6.6.159.jar:?] at org.wso2.carbon.apimgt.impl.utils.APIUtil.getCache(APIUtil.java:8453) ~[org.wso2.carbon.apimgt.impl_6.6.159.jar:?] at org.wso2.carbon.apimgt.impl.caching.CacheProvider.getCache_aroundBody34(CacheProvider.java:165) ~[org.wso2.carbon.apimgt.impl_6.6.159.jar:?] at org.wso2.carbon.apimgt.impl.caching.CacheProvider.getCache(CacheProvider.java:164) ~[org.wso2.carbon.apimgt.impl_6.6.159.jar:?] at org.wso2.carbon.apimgt.impl.caching.CacheProvider.getGatewayTokenCache_aroundBody2(CacheProvider.java:46) ~[org.wso2.carbon.apimgt.impl_6.6.159.jar:?] at org.wso2.carbon.apimgt.impl.caching.CacheProvider.getGatewayTokenCache(CacheProvider.java:45) ~[org.wso2.carbon.apimgt.impl_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.jwt.JWTValidator.getGatewayTokenCache_aroundBody16(JWTValidator.java:680) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.jwt.JWTValidator.getGatewayTokenCache(JWTValidator.java:679) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.jwt.JWTValidator.authenticate_aroundBody0(JWTValidator.java:130) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.jwt.JWTValidator.authenticate(JWTValidator.java:110) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.oauth.OAuthAuthenticator.authenticate_aroundBody4(OAuthAuthenticator.java:334) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.oauth.OAuthAuthenticator.authenticate(OAuthAuthenticator.java:109) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler.isAuthenticate_aroundBody42(APIAuthenticationHandler.java:419) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler.isAuthenticate(APIAuthenticationHandler.java:413) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler.handleRequest_aroundBody36(APIAuthenticationHandler.java:349) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler.handleRequest(APIAuthenticationHandler.java:320) ~[org.wso2.carbon.apimgt.gateway_6.6.159.jar:?] at org.apache.synapse.rest.API.process(API.java:367) ~[synapse-core_2.1.7.wso2v147.jar:2.1.7-wso2v147] at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:149) ~[synapse-core_2.1.7.wso2v147.jar:2.1.7-wso2v147] at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:95) ~[synapse-core_2.1.7.wso2v147.jar:2.1.7-wso2v147] at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71) ~[synapse-core_2.1.7.wso2v147.jar:2.1.7-wso2v147] at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:327) ~[synapse-core_2.1.7.wso2v147.jar:2.1.7-wso2v147] at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:98) ~[synapse-core_2.1.7.wso2v147.jar:2.1.7-wso2v147] at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) ~[axis2_1.6.1.wso2v41.jar:?] at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:368) [synapse-nhttp-transport_2.1.7.wso2v147.jar:?] at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:189) [synapse-nhttp-transport_2.1.7.wso2v147.jar:?] at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) [axis2_1.6.1.wso2v41.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]

Buggy code is at [1] Please check the relevant kernel version for 3.1.0.

[1] https://github.com/wso2/carbon-kernel/blob/v4.4.26/core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/multitenancy/utils/TenantAxisUtils.java#L477-L492

Steps to reproduce:

  1. Login to the publisher with the super tenant
  2. Create an API which has a resource as follows
t
  1. Login to the devportal as Super tenant and subscribe to the API
  2. Try invoking the above resource.

Affected Product Version:

APIM 3.1.0

TanyaM commented 4 years ago

Reported by a customer