-
Notifications
You must be signed in to change notification settings - Fork 22k
Deprecate using class level querying methods if the receiver scope regarded as leaked #35280
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
Conversation
…on_relation_create" This reverts commit b67d5c6, reversing changes made to 2e01836. Reason: rails#35186 may cause that silently leaking information when people upgrade the app. We need deprecation first before making this.
jeremy
left a comment
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.
Tricky situation. Great fix!
|
What are the non-"leak" ways a scope can be set after this? Is it only explicit |
|
Yes, since |
|
Maybe I don't get the point of "What are the non-"leak" ways a scope can be set after this?". Can you expand about your concerned situation? @matthewd |
1f3713a to
f86693c
Compare
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.
Reworded.
18f0ca7 to
8a9e02c
Compare
…garded as leaked This deprecates using class level querying methods if the receiver scope regarded as leaked, since rails#32380 and rails#35186 may cause that silently leaking information when people upgrade the app. We need deprecation first before making those.
8a9e02c to
4c6171d
Compare
Follow up of rails#35280, I missed that `AssociationRelation` is using `scoping` and not use `super`.
Related rails#35280, rails#37360, rails#37511. Using `klass.all` in `scoping` would potentially cause the warning. https://buildkite.com/rails/rails/builds/64444#203174d8-b527-4c43-9bd4-44e272f43555/996-1003
|
The code from the documentation for It seems like this deprecation is either too aggressive, or |
|
We have some tests for rails/activerecord/test/cases/relations_test.rb Lines 1415 to 1422 in 30349de
rails/activerecord/test/cases/relations_test.rb Lines 1424 to 1432 in 30349de
Let me know more executable information I can take a closer look at an issue around this deprecation. |
|
It looks really aggressive 🤔 We have a models that generates module Sluggable
extend ActiveSupport::Concern
included do
before_create :set_slug
def generate_slug(payload)
slug = payload.to_slug
if self.class.where(slug: slug).exists? # <------ ¯\_(ツ)_/¯
"#{slug}_#{SecureRandom.hex(6)}"
else
slug
end
end
def sluggable_value
name
end
private
def set_slug
self.slug = generate_slug(sluggable_value) if slug.blank?
end
end
endAnd then I got a lot of deprecation warnings on the line marked above with a comment. Don't sure which scoping |
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/lib/unique_within_region_validator.rb:25) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Similar to previous commits, this fixes the following deprecation error that was propagating when running `task_helpers/imports/tags_spec.rb` DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Classification.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/app/models/classification.rb:512) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Vm.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/spec/lib/rbac/filterer_spec.rb:2086) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727 This specifically was just a fake `Vm` model specifically used for the Rbac specs, so this isn't something that needs to be fixed in the app codebase proper.
Fixes the following deprecation warning in MiqGroup: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from next_sequence at /Users/nicklamuro/code/redhat/manageiq/app/models/miq_group.rb:72) There was a change coming that will prevent leaking scopes in Rails 6.1, and causes a deprecation warning as part of Rails 6.0: - rails/rails#35280 - rails/rails#37727 Since our use case probably benefited from the leaking scope, we needed to support that functionality when it make sense, otherwise default to the .default_scope (aka: self) when appropriate.
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/lib/unique_within_region_validator.rb:25) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Similar to previous commits, this fixes the following deprecation error that was propagating when running `task_helpers/imports/tags_spec.rb` DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Classification.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/app/models/classification.rb:512) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Vm.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/spec/lib/rbac/filterer_spec.rb:2086) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727 This specifically was just a fake `Vm` model specifically used for the Rbac specs, so this isn't something that needs to be fixed in the app codebase proper.
Similar to previous commits, this fixes the following deprecation error that was propagating when running `task_helpers/imports/tags_spec.rb` DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Classification.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/app/models/classification.rb:512) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Vm.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/spec/lib/rbac/filterer_spec.rb:2086) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727 This specifically was just a fake `Vm` model specifically used for the Rbac specs, so this isn't something that needs to be fixed in the app codebase proper.
Fixes the following deprecation warning in MiqGroup: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from next_sequence at /Users/nicklamuro/code/redhat/manageiq/app/models/miq_group.rb:72) There was a change coming that will prevent leaking scopes in Rails 6.1, and causes a deprecation warning as part of Rails 6.0: - rails/rails#35280 - rails/rails#37727 Since our use case probably benefited from the leaking scope, we needed to support that functionality when it make sense, otherwise default to the .default_scope (aka: self) when appropriate.
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/lib/unique_within_region_validator.rb:25) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Similar to previous commits, this fixes the following deprecation error that was propagating when running `task_helpers/imports/tags_spec.rb` DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Classification.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/app/models/classification.rb:512) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Vm.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/spec/lib/rbac/filterer_spec.rb:2086) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727 This specifically was just a fake `Vm` model specifically used for the Rbac specs, so this isn't something that needs to be fixed in the app codebase proper.
Fixes the following deprecation warning in MiqGroup: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from next_sequence at /Users/nicklamuro/code/redhat/manageiq/app/models/miq_group.rb:72) There was a change coming that will prevent leaking scopes in Rails 6.1, and causes a deprecation warning as part of Rails 6.0: - rails/rails#35280 - rails/rails#37727 Since our use case probably benefited from the leaking scope, we needed to support that functionality when it make sense, otherwise default to the .default_scope (aka: self) when appropriate.
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/lib/unique_within_region_validator.rb:25) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Similar to previous commits, this fixes the following deprecation error that was propagating when running `task_helpers/imports/tags_spec.rb` DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Classification.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/app/models/classification.rb:512) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Vm.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/spec/lib/rbac/filterer_spec.rb:2086) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727 This specifically was just a fake `Vm` model specifically used for the Rbac specs, so this isn't something that needs to be fixed in the app codebase proper.
Fixes the following deprecation warning in MiqGroup: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from next_sequence at /Users/nicklamuro/code/redhat/manageiq/app/models/miq_group.rb:72) There was a change coming that will prevent leaking scopes in Rails 6.1, and causes a deprecation warning as part of Rails 6.0: - rails/rails#35280 - rails/rails#37727 Since our use case probably benefited from the leaking scope, we needed to support that functionality when it make sense, otherwise default to the .default_scope (aka: self) when appropriate.
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/lib/unique_within_region_validator.rb:25) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Similar to previous commits, this fixes the following deprecation error that was propagating when running `task_helpers/imports/tags_spec.rb` DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Classification.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/app/models/classification.rb:512) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Vm.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/spec/lib/rbac/filterer_spec.rb:2086) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727 This specifically was just a fake `Vm` model specifically used for the Rbac specs, so this isn't something that needs to be fixed in the app codebase proper.
Fixes the following deprecation warning in MiqGroup: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from next_sequence at /Users/nicklamuro/code/redhat/manageiq/app/models/miq_group.rb:72) There was a change coming that will prevent leaking scopes in Rails 6.1, and causes a deprecation warning as part of Rails 6.0: - rails/rails#35280 - rails/rails#37727 Since our use case probably benefited from the leaking scope, we needed to support that functionality when it make sense, otherwise default to the .default_scope (aka: self) when appropriate.
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `MiqGroup.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/lib/unique_within_region_validator.rb:25) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Similar to previous commits, this fixes the following deprecation error that was propagating when running `task_helpers/imports/tags_spec.rb` DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Classification.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/app/models/classification.rb:512) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727
Adds a fix for the following deprecation error: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `create!` in Rails 6.1. To continue using the scoped relation, pass it into the block directly. To instead access the full set of models, as Rails 6.1 will, use `Vm.default_scoped`. (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/spec/lib/rbac/filterer_spec.rb:2086) This was added to fix "leaking scopes" in Rails 6.1, but was added as a deprecation warning first: - rails/rails#35280 - rails/rails#37727 This specifically was just a fake `Vm` model specifically used for the Rbac specs, so this isn't something that needs to be fixed in the app codebase proper.
… callback Details from Rails 6: - rails/rails#35186 - rails/rails#35280
… callback Details from Rails 6: - rails/rails#35186 - rails/rails#35280
This deprecates using class level querying methods if the receiver scope
regarded as leaked, since #32380 and #35186 may cause that silently
leaking information when people upgrade the app.
We need deprecation first before making those.