Skip to content

THREESCALE-12434: Migrate from protected attributes to strong parameters - Part 2#4249

Open
mayorova wants to merge 4 commits intostrong-params-part1from
strong-params-part2
Open

THREESCALE-12434: Migrate from protected attributes to strong parameters - Part 2#4249
mayorova wants to merge 4 commits intostrong-params-part1from
strong-params-part2

Conversation

@mayorova
Copy link
Copy Markdown
Contributor

@mayorova mayorova commented Mar 11, 2026

What this PR does / why we need it:

This is part 2 of the migration from protected attributes to strong parameters. See the first part in #4248

Protected attributes is an old Rails feature which was deprecated a long time ago. We were using protected_attributes_continued gem to keep it working, but now it's also discontinued and does not support Rails 7+, so it's a blocker for upgrading to Rails 7.2 for us.

This Part 2 handles the models that can have custom attributes through FieldsDefinitions - Account, User, Cinstance.

Which issue(s) this PR fixes

https://redhat.atlassian.net/browse/THREESCALE-12434

Verification steps

All tests should pass, and all features should work as before.

Special notes for your reviewer:

Copy link
Copy Markdown
Contributor

@jlledom jlledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments come from the other PR. Also, I still see a lot of

Comment thread app/controllers/master/api/providers_controller.rb Outdated
Comment thread app/lib/signup/account_manager.rb Outdated
Comment thread app/controllers/provider/admin/account/users_controller.rb Outdated
Comment thread app/lib/authentication/strategy/oauth2.rb
@mayorova mayorova force-pushed the strong-params-part2 branch 2 times, most recently from 38e277c to db25ecf Compare March 13, 2026 00:03
@account_params ||= begin
defined_fields_names = buyer_account.defined_fields_names
allowed_attrs = defined_fields_names - %w(billing_address) + %w(name)
nested_params = { extra_fields: buyer_account.defined_extra_fields_names }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is different from other API controller, which have only plain parameters, i.e. not nested under extra_fields.
I only did this because there was an existing test in test/integration/admin/api/accounts_controller_test.rb which was passing extra params in this way:

params: update_params.merge(extra_fields: { my_field: 4 })

I also added a check that plain parameters would also work.

Now I'm not sure if other API controllers need to accept both ways too 🤔

@mayorova mayorova force-pushed the strong-params-part2 branch 6 times, most recently from a676b21 to 8b5a6de Compare March 17, 2026 15:36
@mayorova mayorova changed the base branch from master to strong-params-part1 March 17, 2026 17:19
@mayorova mayorova changed the title Strong params part2 THREESCALE-12434: Migrate from protected attributes to strong parameters - Part 2 Mar 17, 2026
@mayorova mayorova force-pushed the strong-params-part1 branch from 0b8ead4 to 6c69623 Compare March 18, 2026 15:35
@mayorova mayorova force-pushed the strong-params-part2 branch 3 times, most recently from 498f50b to 706cacb Compare March 18, 2026 17:47
@mayorova mayorova force-pushed the strong-params-part1 branch 3 times, most recently from a08b299 to d3304a9 Compare March 19, 2026 12:26
@mayorova mayorova force-pushed the strong-params-part2 branch 2 times, most recently from e2771a2 to 1abbc5c Compare March 19, 2026 15:32
@mayorova mayorova marked this pull request as ready for review March 19, 2026 15:34
@qltysh
Copy link
Copy Markdown

qltysh Bot commented Mar 19, 2026

❌ 28 blocking issues (30 total)

Tool Category Rule Count
reek Lint Partners::ProvidersController#assign_account_attributes refers to 'account' more than self (maybe move it to another class?) 10
reek Lint Partners::ProvidersController#assign_account_attributes has approx 8 statements 3
reek Lint Provider::SignupsController#track_user calls 'analytics_session.traits' 2 times 2
rubocop Lint Assignment Branch Condition size for create\_account is too high. [<5, 22, 6> 23.35/20] 2
reek Lint Signup::AccountManager takes parameters ['defaults', 'plans'] to 3 methods 2
reek Lint Signup::AccountManager#assign_attributes_for_account is controlled by argument 'validate_fields' 2
brakeman Vulnerability Specify exact keys allowed for mass assignment instead of using permit\! which allows any keys. 1
rubocop Lint Avoid parameter lists longer than 5 parameters. [6/5] 1
reek Lint Signup::AccountManager#create has 6 parameters 1
reek Lint Signup::AccountManager#create has boolean parameter 'validate_fields' 1
rubocop Lint Perceived complexity for create is too high. [9/8] 1
reek Lint DeveloperPortal::SignupController has missing safe method 'signup_user!' 1
rubocop Lint Predicate method names should end with ?. 1
qlty Structure Function with many parameters (count = 6): create 2

@mayorova mayorova force-pushed the strong-params-part1 branch 2 times, most recently from 4b5523f to 5f946c2 Compare April 20, 2026 10:07
@mayorova mayorova force-pushed the strong-params-part2 branch from d2c96f4 to 6fe7923 Compare April 23, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants