Skip to content

Conversation

@MauricioReisdoefer
Copy link
Contributor

Fixing errors for:

#19 issue (Database commits even with http errors)
To solve i added a message['status']. Added this in middleware.py:

try:
            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
        finally:
            db_session.remove()

#25 issue (Workflow for publishing docs run inside forks)
And this in the workflow:

 deploy:
    if: github.event.repository.fork == false
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

Now it verifies if the github.event is a fork repository.

Copy link
Contributor

@kasimlyee kasimlyee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MauricioReisdoefer Thank you, the status approach I think can fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants