localstack icon indicating copy to clipboard operation
localstack copied to clipboard

Getting "Error forwarding request: list index out of range" error

Open tobilg opened this issue 8 years ago • 16 comments

I'm running localstack via Docker and the following docker-compose.yml:

version: '2.1'

services:
  localstack:
    image: localstack/localstack:0.8.4
    ports:
      - "4567-4583:4567-4583"
      - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=lambda,s3,redshift,cloudformation
      - DEFAULT_REGION=eu-central-1
      - PORT_WEB_UI=8080
      - LAMBDA_EXECUTOR=docker

When doing a serverless deploy --stage local via serverless-localstack I get the following error (debug enabled):

localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:27:34] "POST / HTTP/1.1" 500 -
localstack_1  | Error on request:
localstack_1  | Traceback (most recent call last):
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
localstack_1  | execute(self.server.app)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 258, in execute
localstack_1  | application_iter = app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/server.py", line 93, in __call__
localstack_1  | return backend_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
localstack_1  | return self.wsgi_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
localstack_1  | response = self.make_response(self.handle_exception(e))
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
localstack_1  | response = self.full_dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
localstack_1  | rv = self.handle_user_exception(e)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
localstack_1  | rv = self.dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
localstack_1  | return self.view_functions[rule.endpoint](**req.view_args)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/utils.py", line 139, in __call__
localstack_1  | result = self.callback(request, request.url, {})
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 115, in dispatch
localstack_1  | return cls()._dispatch(*args, **kwargs)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 183, in _dispatch
localstack_1  | return self.call_action()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 257, in call_action
localstack_1  | response = method()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 228, in update_stack
localstack_1  | stack_body = self._get_stack_from_s3_url(template_url)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 38, in _get_stack_from_s3_url
localstack_1  | return key.value.decode("utf-8")
localstack_1  | AttributeError: 'NoneType' object has no attribute 'value'
localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:27:34] "POST / HTTP/1.1" 200 -
localstack_1  | 2018-01-24T12:27:34:ERROR:localstack.services.generic_proxy: Error forwarding request: list index out of range Traceback (most recent call last):
localstack_1  |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 215, in forward
localstack_1  |     updated_response = self.proxy.update_listener.return_response(**kwargs)
localstack_1  |   File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_listener.py", line 183, in return_response
localstack_1  |     template_deployer.deploy_template(template, req_data.get('StackName')[0])
localstack_1  |   File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 485, in deploy_template
localstack_1  |     resource['__details__'] = stack_resources[0]
localstack_1  | IndexError: list index out of range

What could be the reason for this error? The Serverless stack can be deployed to AWS without problem.

tobilg avatar Jan 24 '18 12:01 tobilg

Thanks for reporting @tobilg . There have been some changes recently that might potentially fix this issue, in particular #548 . Can you please give it a try with the latest version of the Docker image:

    image: localstack/localstack:latest

You may have to pull the image manually to fetch the latest version:

docker pull localstack/localstack:latest

Thanks

whummer avatar Jan 24 '18 12:01 whummer

Thanks for the very fast response @whummer! When running latest, I get the following (different) error message:

localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:44:11] "POST / HTTP/1.1" 500 -
localstack_1  | Error on request:
localstack_1  | Traceback (most recent call last):
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
localstack_1  | execute(self.server.app)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 258, in execute
localstack_1  | application_iter = app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/server.py", line 93, in __call__
localstack_1  | return backend_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
localstack_1  | return self.wsgi_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
localstack_1  | response = self.make_response(self.handle_exception(e))
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
localstack_1  | response = self.full_dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
localstack_1  | rv = self.handle_user_exception(e)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
localstack_1  | rv = self.dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
localstack_1  | return self.view_functions[rule.endpoint](**req.view_args)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/utils.py", line 139, in __call__
localstack_1  | result = self.callback(request, request.url, {})
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 116, in dispatch
localstack_1  | return cls()._dispatch(*args, **kwargs)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 199, in _dispatch
localstack_1  | return self.call_action()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 273, in call_action
localstack_1  | response = method()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 228, in update_stack
localstack_1  | stack_body = self._get_stack_from_s3_url(template_url)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 38, in _get_stack_from_s3_url
localstack_1  | return key.value.decode("utf-8")
localstack_1  | AttributeError: 'NoneType' object has no attribute 'value'
localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:44:11] "GET /mytestlambda-local-ServerlessDeploymentBucket-6A-Z2100832037/serverless/mytestlambda/local/1516797844980-2018-01-24T12:44:04.980Z/compiled-cloudformation-template.json HTTP/1.1" 200 -
localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:44:11] "POST / HTTP/1.1" 500 -
localstack_1  | Error on request:
localstack_1  | Traceback (most recent call last):
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
localstack_1  | execute(self.server.app)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 258, in execute
localstack_1  | application_iter = app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/server.py", line 93, in __call__
localstack_1  | return backend_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
localstack_1  | return self.wsgi_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
localstack_1  | response = self.make_response(self.handle_exception(e))
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
localstack_1  | response = self.full_dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
localstack_1  | rv = self.handle_user_exception(e)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
localstack_1  | rv = self.dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
localstack_1  | return self.view_functions[rule.endpoint](**req.view_args)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/utils.py", line 139, in __call__
localstack_1  | result = self.callback(request, request.url, {})
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 116, in dispatch
localstack_1  | return cls()._dispatch(*args, **kwargs)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 199, in _dispatch
localstack_1  | return self.call_action()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 273, in call_action
localstack_1  | response = method()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 228, in update_stack
localstack_1  | stack_body = self._get_stack_from_s3_url(template_url)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 38, in _get_stack_from_s3_url
localstack_1  | return key.value.decode("utf-8")
localstack_1  | AttributeError: 'NoneType' object has no attribute 'value'
localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:44:11] "GET /mytestlambda-local-ServerlessDeploymentBucket-6A-Z2100832037/serverless/mytestlambda/local/1516797844980-2018-01-24T12:44:04.980Z/compiled-cloudformation-template.json HTTP/1.1" 200 -
localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:44:11] "POST / HTTP/1.1" 500 -
localstack_1  | Error on request:
localstack_1  | Traceback (most recent call last):
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
localstack_1  | execute(self.server.app)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 258, in execute
localstack_1  | application_iter = app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/server.py", line 93, in __call__
localstack_1  | return backend_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
localstack_1  | return self.wsgi_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
localstack_1  | response = self.make_response(self.handle_exception(e))
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
localstack_1  | response = self.full_dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
localstack_1  | rv = self.handle_user_exception(e)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
localstack_1  | rv = self.dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
localstack_1  | return self.view_functions[rule.endpoint](**req.view_args)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/utils.py", line 139, in __call__
localstack_1  | result = self.callback(request, request.url, {})
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 116, in dispatch
localstack_1  | return cls()._dispatch(*args, **kwargs)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 199, in _dispatch
localstack_1  | return self.call_action()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 273, in call_action
localstack_1  | response = method()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 228, in update_stack
localstack_1  | stack_body = self._get_stack_from_s3_url(template_url)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 38, in _get_stack_from_s3_url
localstack_1  | return key.value.decode("utf-8")
localstack_1  | AttributeError: 'NoneType' object has no attribute 'value'
localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:44:11] "GET /mytestlambda-local-ServerlessDeploymentBucket-6A-Z2100832037/serverless/mytestlambda/local/1516797844980-2018-01-24T12:44:04.980Z/compiled-cloudformation-template.json HTTP/1.1" 200 -
localstack_1  | 127.0.0.1 - - [24/Jan/2018 12:44:11] "POST / HTTP/1.1" 500 -
localstack_1  | Error on request:
localstack_1  | Traceback (most recent call last):
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
localstack_1  | execute(self.server.app)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/werkzeug/serving.py", line 258, in execute
localstack_1  | application_iter = app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/server.py", line 93, in __call__
localstack_1  | return backend_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
localstack_1  | return self.wsgi_app(environ, start_response)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
localstack_1  | response = self.make_response(self.handle_exception(e))
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
localstack_1  | response = self.full_dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
localstack_1  | rv = self.handle_user_exception(e)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
localstack_1  | reraise(exc_type, exc_value, tb)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
localstack_1  | rv = self.dispatch_request()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
localstack_1  | return self.view_functions[rule.endpoint](**req.view_args)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/utils.py", line 139, in __call__
localstack_1  | result = self.callback(request, request.url, {})
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 116, in dispatch
localstack_1  | return cls()._dispatch(*args, **kwargs)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 199, in _dispatch
localstack_1  | return self.call_action()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/core/responses.py", line 273, in call_action
localstack_1  | response = method()
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 228, in update_stack
localstack_1  | stack_body = self._get_stack_from_s3_url(template_url)
localstack_1  | File "/opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py", line 38, in _get_stack_from_s3_url
localstack_1  | return key.value.decode("utf-8")
localstack_1  | AttributeError: 'NoneType' object has no attribute 'value'

tobilg avatar Jan 24 '18 12:01 tobilg

Any updates on this topic? Thanks in advance!

tobilg avatar Jan 29 '18 15:01 tobilg

Hi there! I'm curious as to whether either @tobilg or @whummer made progress on this issue? I'm also using the serverless-localstack plugin and received the original error listed here ("Error forwarding request: list index out of range"). After following @whummer's direction to deploy using the latest docker image, I also received the latest error @tobilg posted above. Here's the Serverless config I'm using: https://pastebin.com/4mXVpLRZ. Thanks!

khalid-richards avatar Feb 01 '18 19:02 khalid-richards

@khalid-richards Unfortunately I wasn’t able to solve it yet. I think it’s either a bug in the plugin or in localstaxk

tobilg avatar Feb 01 '18 19:02 tobilg

The fix is here https://github.com/spulec/moto/pull/1476

cliveli-ea avatar Feb 13 '18 06:02 cliveli-ea

@cliveli-shine Thanks for the info. I guess this needs to be merged first, and then localstack needs to update the requirements?

tobilg avatar Feb 13 '18 16:02 tobilg

@tobilg I think so, before that, you have to apply that change manually

cliveli-ea avatar Feb 13 '18 21:02 cliveli-ea

@cliveli-shine Would you please add some instructions on how to manually apply the change?

jiaming-jx avatar Feb 14 '18 20:02 jiaming-jx

If you are using localstack by docker, replace /opt/code/localstack/.venv/lib/python2.7/site-packages/moto/cloudformation/responses.py with https://raw.githubusercontent.com/cliveli/moto/6e6ed28d790b29e99b400947b0378345432f9bc0/moto/cloudformation/responses.py

You can do it in your Dockerfile

cliveli-ea avatar Feb 14 '18 21:02 cliveli-ea

Any update about this issue I'm the same error

joseSantacruz avatar Feb 18 '18 02:02 joseSantacruz

Any news on this? Thanks in advance!

tobilg avatar Mar 29 '18 08:03 tobilg

The fix in spulec/moto#1476 has been merged into LocalStack in the meantime. @tobilg @joseSantacruz are you still experiencing this issue, or can we close it? Can you please provide an updated, self-contained example to reproduce the issue? Thanks

whummer avatar May 20 '18 01:05 whummer

Unfortunately I no longer have access to the original project, so I can't verify anymore. Shall I close this issue @whummer, or wait for the potential feedback from the others?

tobilg avatar May 24 '18 07:05 tobilg

I'm having the same issue but in another case: by sending publishing a message to SNS.

awslocal sns publish \
--message '{"sqs":{"id":1,"state":"success"}}' \
--topic-arn arn:aws:sns:eu-central-1:123456789012:PackageBuiltSuccessful

Anybody has got any idea?

GiamPy5 avatar Dec 12 '18 19:12 GiamPy5

@GiampaoloFalqui Looks like the topic ARN is using the wrong account ID (the default should be 000000000000). But more details would be needed to investigate this issue.

Closing this issue - please create follow-up issues with a detailed problem description and steps to reproduce. Thanks

whummer avatar Aug 25 '19 19:08 whummer