Unhandled ValueError on quantity param in product_service - Team 177
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 55/100
Línea de trabajo
Empieza en app.py localizando los endpoints reserve_stock() y release_stock(), y después lee el patrón de validación existente de create_product(). Reproduce una solicitud con una cantidad que no sea un entero, como "abc", null, [] o 3.5; se considera terminado cuando las cantidades malformadas devuelven una respuesta JSON 400 clara en lugar de un 500 no controlado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
The reserve_stock() and release_stock() endpoints both call int() directly on user-supplied input without a try/except guard. If the quantity field in the JSON body is a non-integer-castable value (e.g., "abc", null, [], 3.5), Python raises an unhandled ValueError (or TypeError) that Flask converts to a generic 500 Internal Server Error. At that time we need to showcase them as to enter integer or 400 BAD request with the add of int() logic.
Current Behavior
POST /api/v1/products/<id>/reserve
Body: { "quantity": "abc" }
→ Python raises: ValueError: invalid literal for int() with base 10: 'abc'
→ Flask returns: 500 Internal Server Error (generic HTML or JSON error page)
The raw traceback is logged server-side, and the client receives no useful error message.
in short = if user enter "abc" it showcase 500 status.
Expected Behavior
The endpoint should validate the input gracefully and return a 400 Bad Request with a clear JSON error message such as:
{ "error": "quantity must be a positive integer" }
Location
app.py
Impact
• Callers receive an opaque 500 error instead of actionable 400 feedback.
• Every malformed quantity triggers a 500 logged as a server error, polluting error metrics and potentially triggering false alerts.
• The order_service calls /reserve and /release programmatically. If it ever passes a malformed value, it gets a 503/500 cascading failure instead of a clear rejection.
Suggested Solution
Wrap the int() cast in a try/except, matching the pattern already used in create_product():
add with int(). with some minor logics.
- Lenguaje dominante
- Python
- Estrellas
- 3
- Forks
- 8
- Merge medio
- 1 h 6 min
- PR fusionados (30 d)
- 3
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de keploy/ecommerce_sample_app
-
Improve and restructure README documentation for better clarity Issue 161Posiblemente ocupada @Jerry-145 la tomó hace 252 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
Hardcoded Credentials Security Issue T152Quizá libre de nuevo @Talaviya-Sarthak la tomó hace 253 días y no hay ningún pull request abierto. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 32/100
keploy/ecommerce_sample_app#7 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
keploy/ecommerce_sample_app#6 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
keploy/ecommerce_sample_app#4 · 1 comentario ·
Todos los issues de keploy/ecommerce_sample_app
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/markitdown#2820 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
yt-project/yt#5624 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
NousResearch/hermes-agent#148376 ·
Los mantenedores suelen responder en 1 día