From 063ddc735d2c76d843fe41dced48fcf1f75164e4 Mon Sep 17 00:00:00 2001 From: Mauricio Reisdoefer Date: Mon, 22 Dec 2025 23:26:39 -0300 Subject: [PATCH 1/2] feat: adding dbsessionmiddleware a status_code verification --- jsweb/middleware.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jsweb/middleware.py b/jsweb/middleware.py index ed91bbe..7aa14c8 100644 --- a/jsweb/middleware.py +++ b/jsweb/middleware.py @@ -175,8 +175,24 @@ async def __call__(self, scope, receive, send): from .database import db_session try: - await self.app(scope, receive, send) - db_session.commit() + status_code = None + + async def send_wrapper(message): + nonlocal status_code + if message["type"] == "http.response.start": + status_code = message["status"] + await send(message ) + + await self.app(scope, receive, send_wrapper) + + # Commit only if the response status code is a success (2xx) + # If status_code is None, it means no response was sent, which is an error state + # or a successful response that didn't send headers yet (unlikely in a standard flow). + # It's safer to rollback if status_code is not set or is not 2xx. + if status_code is not None and 200 <= status_code < 300: + db_session.commit() + else: + db_session.rollback() except Exception: db_session.rollback() raise From ed5d046635bcdd6a18d4ef7dc82a5b8694cb876b Mon Sep 17 00:00:00 2001 From: Mauricio Reisdoefer Date: Mon, 22 Dec 2025 23:33:38 -0300 Subject: [PATCH 2/2] fix: fixing CI Publish docs --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d88de92..0e07ea5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,14 +4,11 @@ on: branches: - main -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: group: "pages" cancel-in-progress: false @@ -41,6 +38,7 @@ jobs: path: 'site' deploy: + if: github.event.repository.fork == false environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }}