LAMaglan / FinalFantasyFast

Simple microservice that displays data of select characters, monsters, and games from the Final Fantasy series
0 stars 0 forks source link

address sanitzation issue in backend (monster endpoints) #26

Closed LAMaglan closed 2 months ago

LAMaglan commented 2 months ago

might be type issue/validation with SQL


@router.get("/monsters/", response_model=List[Monster])
def get_characters(name: Optional[str] = None, game: Optional[str] = None, db: Session = Depends(get_db)):
    filters = {}
    if name:
        filters['name'] = name
    if game:
        filters['game'] = game

    monsters = crud.get_monsters(db, **filters)
    if not monsters:
        raise HTTPException(status_code=404, detail="Characters not found")
    else:
        # Sanitize response data
        sanitized_monsters = []
        for monster in monsters:
            if monster.elementalAffinity is None:
                monster.elementalAffinity = ""
            sanitized_monsters.append(monster)

        return sanitized_monsters
``
LAMaglan commented 2 months ago

Prevents some monsters from being displayed (currently only "Chocobo")

LAMaglan commented 2 months ago

Investigate if still an issue

LAMaglan commented 2 months ago

Not in use, all done in client-side...