-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add limit 1 if required first value from query result #33672
Conversation
return self.get_session.scalar( | ||
select(self.registeruser_mode) | ||
.where(self.registeruser_model.registration_hash == registration_hash) | ||
.limit(1) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exposes a problem that might not be entirely in scope of the PR. If there is a hash cache, this lookup may return a wrong user and cause a security vulnarability. We should really either add a unique constraint to registration_hash
, or use one_or_none
here instead; both would remove the need to add a limit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I keep this changes or better revert it back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep it. We’re not sure how to change this code yet and adding this limit would be useful before we figure things out.
(cherry picked from commit e8ba579)
Add missing Limit 1 for
sqlachemy.session.scalar
where:^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.