Skip to content
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

Namespaces in Rails are not resolved correctly #58

Closed
zpieslak opened this issue Jan 29, 2018 · 6 comments
Closed

Namespaces in Rails are not resolved correctly #58

zpieslak opened this issue Jan 29, 2018 · 6 comments
Labels
outdated Inactive - Outdated

Comments

@zpieslak
Copy link
Contributor

One more issue that that come out during the integration with Rails app. Currently I have it fixed within the app, but it would be nice to have it done inside the gem.

Current Behavior

When using multiple files, with multiple key-pairs in Rails app, the keys are not loaded properly, which leads to DecryptionFailure.

Steps to Reproduce

Suppose I have two files with two-key pairs and I'm running rails c in development environment on host myhostname.

# File settings.yml

development:
  some_key: some_value

# File settings-myhostname.yml

development:
  some_other_key: some_other_value

The result is DecryptionFailure and rails console stops. But when I run chamber show it works fine, and the namespaces are resolved correctly.

Expected Behavior or New Behavior

The rails app runs properly when changing file to

Chamber.load(basepath: ::Rails.root.join('config'))

@jfelchner
Copy link
Collaborator

jfelchner commented Jan 29, 2018

@zpieslak thanks for the additional report! Can you create a rails new with the minimal amount of stuff necessary to reproduce this?

@zpieslak
Copy link
Contributor Author

@jfelchner Please find the repository here. I put the instructions in README.

@jfelchner
Copy link
Collaborator

@zpieslak I'm going to knock this and your PR out next weekend. Sorry for the delay!

@zpieslak
Copy link
Contributor Author

@jfelchner OK, looking forward to see the results! I'm currently using own fork, but I would like to use your gem directly.

jfelchner added a commit that referenced this issue May 29, 2019
Why This Change Is Necessary
========================================================================

When a namespace was being passed in as a Hash (as is the default for
our Rails integration), the namespaces weren't being translated to an
array of namespaces, which is what the rest of the library expects.

This was working correctly for the CLI commands because they rely on the
fact that the system will pass through default values, but inside of the
server or the console, this was not working correctly.

Additionally, if a lambda or proc is passed in as a value, it was not
being `call`ed and therefore the value was not resolving.

How These Changes Address the Issue
========================================================================

We now convert hashes passed to the ContextResolver into an array of the
hash's values as well as call procs and lambdas if they are passed in.

Side Effects Caused By This Change
========================================================================

None known.

------------------------------------------------------------------------
Actions:
  * References #58
@jfelchner
Copy link
Collaborator

@zpieslak this was a MAJOR issue and I'm mad that it took me this long to get this fixed. This will go out in the next release (probably later tonight).

Thanks again for reporting this (and the patience).

jfelchner added a commit that referenced this issue May 29, 2019
Why This Change Is Necessary
========================================================================

When a namespace was being passed in as a Hash (as is the default for
our Rails integration), the namespaces weren't being translated to an
array of namespaces, which is what the rest of the library expects.

This was working correctly for the CLI commands because they rely on the
fact that the system will pass through default values, but inside of the
server or the console, this was not working correctly.

Additionally, if a lambda or proc is passed in as a value, it was not
being `call`ed and therefore the value was not resolving.

How These Changes Address the Issue
========================================================================

We now convert hashes passed to the ContextResolver into an array of the
hash's values as well as call procs and lambdas if they are passed in.

Side Effects Caused By This Change
========================================================================

None known.

------------------------------------------------------------------------
Actions:
  * References #58
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the outdated Inactive - Outdated label Dec 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated Inactive - Outdated
Development

No branches or pull requests

2 participants