Error - Request failed with status code 503 Large portfolio is not supported in your current plan

Facing the issue when I run the application: Large portfolio is not supported in your current plan.

Output of ‘python3 dashboard.py --json ~/workspace/annual-return-app/module7-error.json’ is:

Namespace(json=’/home/crio-user/workspace/annual-return-app/module7-error.json’)
http://localhost:8081/portfolio/analyze {
“name”: “Anand”,
“portfolioTrades”: [
{
“symbol”: “AAPL”,
“quantity”: 100,
“tradeType”: “BUY”,
“purchaseDate”: “2019-01-02”
},
{
“symbol”: “MSFT”,
“quantity”: 10,
“tradeType”: “BUY”,
“purchaseDate”: “2019-01-02”
},
{
“symbol”: “GOOGL”,
“quantity”: 50,
“tradeType”: “BUY”,
“purchaseDate”: “2019-01-02”
},
{
“symbol”: “CSCO”,
“quantity”: 100,
“tradeType”: “BUY”,
“purchaseDate”: “2019-01-02”
},
{
“symbol”: “CTS”,
“quantity”: 10,
“tradeType”: “BUY”,
“purchaseDate”: “2019-01-02”
},
{
“symbol”: “AAA”,
“quantity”: 50,
“tradeType”: “BUY”,
“purchaseDate”: “2019-01-02”
}
]
}
<Response [503]>
{
“timestamp”: “2020-06-14T12:29:41.926+0000”,
“status”: 503,
“error”: “Service Unavailable”,
“message”: “Provider error”,
“trace”: “org.springframework.web.server.ResponseStatusException: 503 SERVICE_UNAVAILABLE “Provider error”; nested exception is java.lang.NullPointerException\n\tat com.crio.stock.annualreturnapp.AnnualReturnsController.calculateReturns(AnnualReturnsController.java:48)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)\n\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)\n\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:660)\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)\n\tat org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:747)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)\n\tat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)\n\tat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)\n\tat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1591)\n\tat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tat java.lang.Thread.run(Thread.java:748)\nCaused by: java.lang.NullPointerException\n\tat com.crio.warmup.stock.portfolio.PortfolioManagerImpl.getStockQuote(PortfolioManagerImpl.java:138)\n\tat com.crio.warmup.stock.portfolio.PortfolioManagerImpl.getAnnualizedReturn(PortfolioManagerImpl.java:79)\n\tat com.crio.warmup.stock.portfolio.PortfolioManagerImpl.calculateAnnualizedReturn(PortfolioManagerImpl.java:107)\n\tat com.crio.stock.annualreturnapp.AnnualReturnsController.calculateReturns(AnnualReturnsController.java:42)\n\t… 51 more\n”,
“path”: “/portfolio/analyze”
}

Hi @Nitin529,

Yes, it’s an error. But no, it’s not something we need to resolve. It’s exactly what we want the users to see.

When we tried out the setup tasks while starting out with Module 7, you would’ve seen the dashboard UI throwing out the entire stack trace in the display, right?

We resolved the issue by handling the exceptions causes when the API limit hits the limit and other cases like for empty response. This was done by re-throwing the original exceptions (be it Runtime or Null Pointer exceptions) with a custom StockQuoteService exception. Due to this, the client (annual-return-app) can now check if the thrown exception is StockQuoteService and if so handle it appropriately as they wish. In this case they choose to display the message “Large portfolio is not supported in your current plan”

Regarding the Python utility, there also we can choose to use a try-catch statement to handle the exceptions suitably

The different in the stack trace once we handle exceptions in our Alphavantage/Tiingoservice classes is this


ie, our clients get more context about the error instead of just a general error like Null Pointer Exception

2 Likes

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.