Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

AWS SAM expects an integer status code #23

Closed
wants to merge 1 commit into from
Closed

Conversation

mathom
Copy link

@mathom mathom commented Feb 12, 2019

The current response returns a stringified statusCode. This jams up AWS SAM when it's ran locally:

2019-02-12 11:04:31 statusCode must be a positive int

Here's the SAM setup to reproduce this:

requirements.txt:

aws-wsgi==0.0.8
Flask==1.0.2

api.py:

import awsgi
from flask import jsonify, Flask

app = Flask(__name__)

@app.route('/')
def index():
    return jsonify(message='OK')

def lambda_handler(event, context):
    return awsgi.response(app, event, context)

template.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
  AppExample:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: api.lambda_handler
      Runtime: python3.6
      CodeUri: .
      Events:
        HTTPRoot:
          Type: Api
          Properties:
            Path: /
            Method: any

Test locally:

sam build && sam local start-api --template .aws-sam/template.yaml

@slank
Copy link
Owner

slank commented Feb 15, 2019

@mathom Thanks for this very well-written PR! Merging this would break backward compatibility, and after a little digging I think the solution would be to fix SAM CLI to handle a string statusCode.

I'm working on that PR now and once it's released I'll decline this one. Be back in a bit with a link to that.

@slank
Copy link
Owner

slank commented Feb 15, 2019

SAM CLI PR: aws/aws-sam-cli#1013

@mathom
Copy link
Author

mathom commented Feb 15, 2019

Great, thanks for the quick response!

@mathom mathom closed this Feb 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants