diff --git a/firefly/app.py b/firefly/app.py
index b53fced..3a22377 100644
--- a/firefly/app.py
+++ b/firefly/app.py
@@ -79,7 +79,11 @@ class FireflyFunction(object):
         if self.options.get("internal", False):
             return self.make_response(self.function())
 
-        kwargs = self.get_inputs(request)
+        try:
+            kwargs = self.get_inputs(request)
+        except ValueError as err:
+            return self.make_response({"error": str(err)}, status=400)
+
         try:
             validate_args(self.function, kwargs)
         except ValidationError as err:

Incorrect HTTP Error Codes
When a request is made to a firefly server with data in invalid format like:

```
curl -i -d '{"a": [5 8]}' https://0.0.0.0:8080/predict
```
instead of
```
curl -i -d '{"a": [5, 8]}' https://0.0.0.0:8080/predict
```
the server returns `500 Internal Server Error`. But in such cases, the server should return `400 Bad Request` or `422 Unprocessable Entity` as the payload data is not in the required format.
diff --git a/tests/test_app.py b/tests/test_app.py
index 687cdc7..ab3db5c 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -88,6 +88,14 @@ class TestFireflyFunction:
         assert response.status == '200 OK'
         assert response.text == '9'
 
+    def test_call_for_bad_request(self):
+        def sum(a):
+            return sum(a)
+        func = FireflyFunction(sum)
+        request = Request.blank("/sum", POST='{"a": [3 8]}')
+        response = func(request)
+        assert response.status == '400 Bad Request'
+
     @py2_only
     def test_generate_signature(self):
         def sample_function(x, one="hey", two=None, **kwargs):

pip install -e .
parse_log_pytest
requirements.txt
pytest>=3.1.1 pytest
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
chardet==3.0.4
-e git+https://github.com/rorodata/firefly.git@e87d457f64da90c4993b19c9fa47c1393baec891#egg=Firefly
gunicorn==19.7.1
idna==2.5
importlib-metadata==4.8.3
iniconfig==1.1.1
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
PyYAML==3.12
requests==2.18.1
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.21.1
WebOb==1.7.2
zipp==3.6.0

name: firefly
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - chardet==3.0.4
      - gunicorn==19.7.1
      - idna==2.5
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pyyaml==3.12
      - requests==2.18.1
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.21.1
      - webob==1.7.2
      - zipp==3.6.0
prefix: /opt/conda/envs/firefly

tests/test_app.py::TestFireflyFunction::test_call_for_bad_request
tests/test_app.py::TestFirefly::test_generate_function_list tests/test_app.py::TestFirefly::test_generate_function_list_for_func_name tests/test_app.py::TestFirefly::test_function_call tests/test_app.py::TestFirefly::test_auth_failure tests/test_app.py::TestFirefly::test_http_error_404 tests/test_app.py::TestFireflyFunction::test_call tests/test_app.py::TestFireflyFunction::test_generate_signature_py3
firefly/app.py
firefly/app.py