Skip to content

No database error visibility #46

Description

@SAB13711

When there is a database error, it does not show the error that blocked the database. Perhaps there is also not sufficient logic to stop the process when something fails.

Below is a snippet of code that calls an ORM object:

    def get_gift_cards_for_user(self, email: str) -> dict:
        """
        Returns all the gift cards for a specific user email.
        :param email: str -- the user's email
        :return:
        {
            "success": bool,
            "code": int,
            "msg": str,
            "error": str | None,
            "created_gift_cards": list,
            "owned_gift_cards": list
        }
        """
        try:
            Log.debug(
                "Getting created gift cards for user",
                email=email
            )
            created_gift_cards = GiftCard.where("created_by_email = ? AND is_deleted = 0", [email])

            Log.debug(
                "Getting owned gift cards for user",
                email=email
            )
            owned_gift_cards = GiftCard.where("owned_by_email = ? AND is_deleted = 0", [email])

            Log.debug(
                "Returning gift cards for user",
                email=email
            )
            return OperationResult(
                success=True,
                code=200,
                msg="Returning gift cards",
                data={
                    "created_gift_cards": [
                        self._enrich_gift_card(gc) for gc in created_gift_cards
                    ],
                    "owned_gift_cards": [
                        self._enrich_gift_card(gc) for gc in owned_gift_cards
                    ]
                }
            ).to_dict()

        except Exception as e:
            return self._error_result(500, "Could not get gift cards for user", str(e))

And here is the log that i see:

2026-06-08 11:16:47.722 |   |  
-- | -- | --
  |   | 2026-06-08 11:16:47.722 | 2026-06-08T09:16:47.722Z [ERROR  ] [b83e41207149e7ea80c873ca9353e0dd] [get_gift_cards_for_user] returning failed result: code:500, msg:Could not get gift cards for user, error:current transaction is aborted, commands ignored until end of transaction block |  
  |   | 2026-06-08 11:16:47.719 | 2026-06-08T09:16:47.718Z [DEBUG  ] [b83e41207149e7ea80c873ca9353e0dd] Getting created gift cards for user {"email": "schalk@codeinfinity.co.za"}

There are no logs after that point and it is the first point that a database call is made. It seems the very first call is already saying that the database connection is blocked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions