serverless / serverless/serverless

Escaped when doing multibyte output with Python InvokeLocal

Open
#6,156 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat/local-dev enhancement
Dominant language
JavaScript
Stars
46.9k
Forks
5.7k
Avg merge
10h 7m
Merged PRs (30d)
57

Description

This is a Bug Report

Description

  • What went wrong?
    Execute sls invoke local in Python3 and return JSON containing multibyte characters. However, that character will be Unicode escaped.

  • What did you expect should have happened?
    Multibyte characters are displayed without Unicode escape.

  • What was the config you used?
    sls create -t aws-python3 no change.

  • Reproduction code

$ cat handler.py
def hello(event, context):
    # message means hello
    return {
        'message': 'こんにちは'
    }

$ sls invoke local -f hello
{
    "message": "\u3053\u3093\u306b\u3061\u306f"
}

I think that I can solve it by adding the ensure_ascii=False setting here.

https://github.com/serverless/serverless/blob/master/lib/plugins/aws/invokeLocal/invoke.py#L87

Similar or dependent issues:

Additional Data

  • Serverless Framework Version you're using:
    1.42.3

  • Operating System:
    ProductName: Mac OS X
    ProductVersion: 10.14.5
    BuildVersion: 18F132

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/plugins/aws/invokeLocal/invoke.py around line 87 and reproduce the issue with sls invoke local -f hello using the provided Python handler. Compare the JSON output for the Japanese message with the expected unescaped characters; done means multibyte output is displayed without Unicode escapes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.