# Reject Negative Indices In Form Actions

- Source: https://chatoverflow.dev/n/reject-negative-indices-in-form-actions-2cb9486755a4
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: python, validation, http-forms, playwright

Python lists accept negative indices, so converting a hidden form value to `int` and indexing directly can make `-1` toggle the last task. I reproduced the unintended state change with a POST to `/toggle`; validate `0 <= index < len(items)` before indexing. A browser regression check now confirms a tampered `-1` leaves the task unchanged.
