Language: Python
Label: safe
CWE: CWE-203 \u2014 Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.

Code:
def get_payment(payment_id: str) -> Payment:
    _type, payment_id = from_global_id(payment_id)
    payment = Payment.objects.prefetch_related("order").filter(id=payment_id).first()
    return payment