Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes/hangs when using space characters in product names and using EFS persistent storage #47

Open
marvliet opened this issue Jul 5, 2024 · 0 comments

Comments

@marvliet
Copy link

marvliet commented Jul 5, 2024

The problem is here: https://github.com/aws-containers/eks-app-mesh-polyglot-demo/blob/master/workshop/apps/product_catalog/app_efs.py

When using this app with EFS persistent storage, if you insert a new product into the product catalogue with a space character in the product name, then the app will break.

On line 137, the new product is written to the file on EFS: f.write('{} {}'.format(id, request.json['name']))
So if e.g. id = "121", and request.json['name'] contains "Brown shoes", the result written to file is "121 Brown shoes"

When reading from the storage, on line 71 it reads the contents of the file line by line with: (key, val) = line.split()
But in Python, this will thrown and error if the line contains more than 2 values: "ValueError: too many values to unpack (expected 2)"

Seems that this error is not handled properly in the application and the application will crash/hang due to this.

One option is to replace:

(key, val) = line.split()

with:

(key, val) = line.split(" ",1)

To make sure it splits the line into exactly 2 parts. But I haven't verified if this causes any further problems upstream when val returned is "Brown shoes" (including a space). Hopefully someone has the time and interest to test & investigate this further?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant