-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
deep symbolize keys on secrets.yml #26929
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
Can you add a test case for this? |
@sgrif I would love too. Could you point me to where tests for secret.yml loading are currently being done? Would this be the correct location? https://github.com/rails/rails/blob/master/railties/test/application/configuration_test.rb#L446 |
Yes, those tests which are creating |
Thanks. I'll add those after after work today. |
Tests have been added. Other than just consistency I feel deep serializing works better because it allows you to setup configurations with many options by just passing the hash in. For instance |
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.
Could you add a CHANGELOG entry and squash your commits? Even that is small it is a breaking change.
9f78466
to
0066f57
Compare
@maclover7 I did as you requested but got an conflict on CHANGELOG.md so I merged in master but can't seem to squash the merge. Also weirdly after I merged in master, travis checks aren't passing... Any suggestions? |
@elorest hmm, do you have the latest master locally? I believe you should be able to squash down to one commit via |
c1f3fad
to
7102c6c
Compare
@maclover7 I created this pull request from my branch is_deep_symbolize_keys. rebase -i isn't working like normal. It brings up thousands of commits. So I just switch back to master, cherry-picked my commit and then force pushed it back to my is_deep_symbolize_secrets on github. Should be good now. |
@maclover7 Any idea why travis doesn't pass since I merged in master? |
Failures in Travis aren't related to this PR |
Thank you very much for this 👏 |
Does this preserve backward compatibility if I used |
@kirs: yes, absolutely makes sense |
I don't think it is needed. Like I said in the comment above it is fine to have this small backwards incompatible change as it is in the CHANGELOG. |
I considered doing that, but using |
@elorest @rafaelfranca This change breaks some gems. There is much more_indifferent access_ on every request when accessing |
Added a note in the upgrade guide 0541a0d |
This is a small breaking change that we chose to make in 5.1 since the fix can be done with a search and replace tool.
This is a small breaking change that we chose to make in 5.1 since the fix can be done with a search and replace tool.
In Rails 5.1, nested keys are also symbolized cf. rails/rails#26929
In Rails 5.1, nested keys are also symbolized cf. rails/rails#26929
In Rails 5.1, nested keys are also symbolized cf. rails/rails#26929
In Rails 5.1, nested keys are also symbolized cf. rails/rails#26929
Summary
Changed symbolize_keys to deep_symbolize_keys where secrets.yml is loaded in. This allows secret files to contain more complex information without all child keys being strings while parent keys are symbols.
becomes this
Source yaml.
Benchmarks
To do benchmarks I wrote a rake task which loaded the environment, printed the secrets and exited.
With
symbolize_keys
:2.36 real 1.94 user 0.55 sys
2.38 real 1.93 user 0.51 sys
With
deep_symbolize_keys
:2.37 real 1.91 user 0.51 sys
2.31 real 1.89 user 0.49 sys
As you can see there doesn't seem to be a negative effect in load time for this change. I wasn't able to find where the secrets.yml loading was being tested, but if someone could point that out to me I'll add tests as well.