aditeyabaral / spongebob-as-a-service

Converting the SpongeBob Mocking Meme into a Service to redefine the meaning of SaaS
https://spongebob-service.herokuapp.com
9 stars 1 forks source link

Internal Server error when msg length is too long. #8

Open kushurox opened 1 year ago

kushurox commented 1 year ago

I was testing your website and it seems to break when the message length is too large. I have gone through you code and the error seems to be related to the way the msg is being cut into different lines. Even after reading the code responsible for it I couldn't understand how it really works. Sorry couldn't help you with more technical details regarding the error!

parameter provided: image

aditeyabaral commented 1 year ago

Could you post the traceback here? Will help someone else pick it up

kushurox commented 1 year ago

the first error is irrelevant to the issue but when you run the code in the local machine you get this traceback

Traceback (most recent call last):
  File "app/saas.py", line 1, in <module>
    from .utils import createMeme
ImportError: attempted relative import with no known parent package

I think you can fix this by changing the code to from utils import ...

as for the main error

Traceback (most recent call last):
  File "/home/kushurox/Desktop/spongebob-as-a-service/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/kushurox/Desktop/spongebob-as-a-service/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/kushurox/Desktop/spongebob-as-a-service/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/kushurox/Desktop/spongebob-as-a-service/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/kushurox/Desktop/spongebob-as-a-service/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/kushurox/Desktop/spongebob-as-a-service/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "app/saas.py", line 37, in meme
    filename = createMeme(captions)
  File "/home/kushurox/Desktop/spongebob-as-a-service/app/utils.py", line 11, in createMeme
    filename = generateImage(captions)
  File "/home/kushurox/Desktop/spongebob-as-a-service/app/utils.py", line 65, in generateImage
    addText(img, position, caption)
  File "/home/kushurox/Desktop/spongebob-as-a-service/app/utils.py", line 121, in addText
    while msg[nextCut] != " ":
IndexError: string index out of range

i think the logic for rendering the text in multiple lines is implemented incorrectly. Ill try my best to read the source when free and come up with solution if it isn't fixed by then by someone else.