ProBoard
Web development
Web developmentPublié 2 août

Link shortener: duplicate short codes crash with 500

Generating a short code does not check for collisions, so `POST /links` sometimes fails.

Description

URL shortener (`store.py`, `app.py`, Flask + SQLite). Problem: new codes are inserted without checking whether the code already exists. As soon as two links get the same generated code the insert violates the primary key and the request fails with a 500. Users see random failures, more often once the table grows. Expected: - `Store.add()` always returns a code that is free; - custom `length` keeps working (we call it with `length=1` in tests, so 200 inserts must succeed); - existing links are never overwritten. Acceptance: `python -m unittest discover -s tests` passes. Ping me and I'll send the repo. I'll pay via PayPal the same day the tests pass.

Compétences

  • Python
  • Flask
  • SQLite