anitab-org / anitab-org/bridge-in-tech-backend

Bug: Unhandled errors and bugs in program creation

Offen
#227 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Category: Coding hacktoberfest Status: Available Type: Bug
Vorherrschende Sprache
Python
Sterne
24
Forks
80
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### Describe the bug
There are a few scenarios where API throws unhandled errors when the request payload contains invalid data. Some examples are:
1. enum validations - e.g. `ContacType` and `Zone` are enums - if the data is not valid, unhandled error is thrown
2. integrity errors -> e.g. too many chars in some string (more than column can hold)
3. datetime format -> if the datetime format is not good

### To Reproduce
Steps to reproduce the behavior:
1. Go to `/organizations/{organization_id}/programs/program`
2. Populate fields of the body (use some invalid data from the description)
3. An error occurs (see some screenshots)

### Expected behavior
1. Add validations to enum fields - only acceptable values (`ContactType`, `Zone`, `ProgramStatus`)
2. Add support for currency - define a few mostly used currencies and/or add defense mechanisms for integrity errors with `try/except`

### Screenshots
Some of the examples:
- Bad date format
![image](https://user-images.githubusercontent.com/16724101/112531235-9e4f8b00-8da7-11eb-9d15-0f14556b250a.png)
- Zone not valid
![image](https://user-images.githubusercontent.com/16724101/112531505-f25a6f80-8da7-11eb-8631-a8d58107b058.png)
- Invalid currency provided (accepts up to 3 characters)
![image](https://user-images.githubusercontent.com/16724101/112531571-056d3f80-8da8-11eb-9ec3-1ad03eed8c91.png) -
- Returns success if `start_date > end_date`

### Desktop (please complete the following information):
- OS: elementary OS 5.1.7 Hera (built on Ubuntu)
- Browser: Google Chrome
- Version: 88.0.4324.182
### Additional context
Add tests to confirm solution to these use-cases. Subtasks:
- [ ] Add validation to enum values
- [ ] Add integrity errors handling
- [ ] Solve currency fields provision - enum or increase limit of the column
- [ ] Validate date format -> format and value (`start_date < end_date`)

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.