ArgumentError: Use `License.feature_available?` for features that cannot be restricted to only a subset of projects or namespaces app/models/project.rb:2910:in `security_training_available?' licensed_feature_available?(:security_training) app/presenters/projects/security/configuration_presenter.rb:28:in `to_h' security_training_enabled: project.security_training_available? app/presenters/projects/security/configuration_presenter.rb:33:in `to_html_data_attribute' data = to_h app/controllers/application_controller.rb:142:in `render' super.tap do app/controllers/application_controller.rb:527:in `set_current_admin' return yield unless Gitlab::CurrentSettings.admin_mode...(198 additional frame(s) were not displayed)ActionView::Template::Error: Use `License.feature_available?` for features that cannot be restricted to only a subset of projects or namespaces
When you click on Enable security Training on the security dashboard screen, you get a 500 error
In turn, ConfigurationPresenter triggers the line that is blowing-up (licensed_feature_available?(:security_training)) in app/models/project.rb via security_training_enabled: project.security_training_available?.
Thanks for the ping and moving this to verification @thiagocsf.
Now that we reverted back the changes introduced here !86639 (merged). We may need to reopen this backend issue #358182 (closed) which was addressed along with frontend changes for the bug. But I will wait until the frontend investigation #358183 (comment 958799299), the frontend issue is reopened again.
@subashis Could you investigate the cause of the error on the backend? In the MR there's a comment thread that suggests it could be caused by adding security_training to GLOBAL_FEATURES in ee/app/models/gitlab_subscriptions/features.rb: !86639 (comment 958909889) but we're unable to reproduce the error locally.
@subashis I looked into this a little, in the original MR I used licensed_feature_available, but this causes the error when the following is done:
Set the environment variable GITLAB_SIMULATE_SAAS to 1
Go to Admin > Settings -> General > "Account and limit" and enable "Allow use of licensed EE features".
I can't reproduce the error locally in the actual app, but @tkuahprovided a spec that does reproduce the error. It looks like the fix is to follow exactly what the error message says, to change licensed_feature_available?(:security_training) to License.feature_available?(:security_training).
I have an example MR to test against: !88886 (closed) would you mind verifying if switching to License.feature_available? is indeed the correct solution? You can verify if it's working properly by going to Security & Compliance -> Configuration and checking if the Vulnerability Management tab is shown:
I have an example MR to test against: !88886 (closed) would you mind verifying if switching to License.feature_available? is indeed the correct solution?
It depends on whether it's a global feature, or not ?
Thanks @dftian. Looks like @dpisek was able to reproduce the issue !86639 (comment 965243425). I was able to reproduce it in spec as well as suggested by @tkuahhere.
I have an example MR to test against: !88886 (closed) would you mind verifying if switching to License.feature_available?
this depends on whether we want the feature in global feature or not. Or we can delete that from global features list. I will go through the requirements one more time, and then will decide and sent an MR.