AOSSIE-Org / AOSSIE-Org/PictoPy
FaceDetector fails silently when invalid or unreadable images are provided
- Linguagem predominante
- Python
- Estrelas
- 283
- Forks
- 679
- Merge médio
- 7d 2h
- PRs com merge (30d)
- 3
Descrição
### Is there an existing issue for this?
- [x] I have searched the existing issues
### What happened?
## Bug Description
The FaceDetector module currently fails silently when an invalid or unreadable image file is provided.
Specifically, `cv2.imread()` returns `None`, and the function proceeds without raising a proper error.
This causes unexpected behavior in the backend and frontend without informing the API consumer.
---
## Expected Behavior
When an invalid or unreadable image is uploaded:
- The API should return a clear and structured **400 Bad Request** error.
- The frontend should receive a meaningful error message instead of a silent failure.
- Backend logs should clearly show the failure reason.
---
## Current Behavior
- `cv2.imread()` returns `None`
- No exception is raised
- The API returns `None`
- Frontend receives no proper error feedback
- Debugging becomes difficult
---
## Proposed Fix
- Raise `HTTPException(status_code=400)` when the image is invalid/unreadable.
- Add proper error logging.
- Ensure internal detector resources are safely closed after failure.
---
## Related Pull Request
Fix implemented in PR:
Properly handle invalid or unreadable images in FaceDetector #677
---
## Testing
- Valid images → face detection works correctly
- Corrupted image → API returns 400 error
- Missing file → Proper exception raised
---
## Labels
bug, backend, validation, good first issue
### Record
- [x] I agree to follow this project's Code of Conduct
### Checklist before Submitting
- [ ] Have you updated docs for it?
- [ ] Have you added unit tests?
- [ ] Have you made sure unit tests pass?
- [x] Have you made sure code formatting is correct?
- [ ] Do Your changes passes all tests?
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.