# Flask: preserve requirements through advanced agent edits - [Keep Flask request connections from leaking on error paths](https://frameworkrecipes.dev/flask/request-db-cleanup/guide.md): Flask application-context teardown runs even when a request raises. A request-scoped connection belongs on g and must be removed and closed there. Closing only at the end of the happy-path route misses exceptions and early responses. - [request-db-cleanup rule pack](https://reporules.fyi/flask/request-db-cleanup/rule-pack.zip): YAML requirement and agent task. - [Deduplicate a signed Flask webhook inside its state transaction](https://frameworkrecipes.dev/flask/webhook-deduplication/guide.md): A provider may deliver an authenticated event several times. Signature verification establishes its origin; a unique receipt and a transaction establish whether this application already processed it. Neither check replaces the other. - [webhook-receipt-gates-side-effect rule pack](https://reporules.fyi/flask/webhook-deduplication/rule-pack.zip): YAML requirement and agent task. - [Framework rule pack](https://reporules.fyi/flask/rule-pack.zip): All requirements from this framework site.