Skip to content

Missing default value can lead to AttributeError #322

Description

@oxesoft

medium

Using getattr without a default value or validation can raise an AttributeError if order_by contains an invalid attribute name. Providing a default (like self.model.id) makes the query more robust.

        column = getattr(self.model, order_by, self.model.id) if order_by else self.model.id

Originally posted by @gemini-code-assist[bot] in #318 (comment)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions