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

fix: Don't mutate original enabled_environments #2275

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ixti
Copy link

@ixti ixti commented Mar 17, 2024

Ensure enabled_environments contains test environment without mutating original list. Otherwise it can cause unexpected spec failures in case original config has unfrozen Array, or fail in attempt to mutate said array.

Alternative approach would be to override Sentry::Configuration#dup to dup underlying arrays and hashes.

See: #2269 (comment)

Copy link

codecov bot commented Mar 20, 2024

Codecov Report

Merging #2275 (ebf04a4) into master (ffffce9) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

❗ Current head ebf04a4 differs from pull request most recent head a573841. Consider uploading reports for the commit a573841 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2275      +/-   ##
==========================================
- Coverage   97.61%   97.56%   -0.05%     
==========================================
  Files         112      112              
  Lines        4154     4155       +1     
==========================================
- Hits         4055     4054       -1     
- Misses         99      101       +2     
Components Coverage Δ
sentry-ruby 98.27% <100.00%> (-0.04%) ⬇️
sentry-rails 95.05% <ø> (-0.18%) ⬇️
sentry-sidekiq 94.70% <ø> (ø)
sentry-resque 90.76% <ø> (ø)
sentry-delayed_job 95.60% <ø> (ø)
sentry-opentelemetry 100.00% <ø> (ø)
Files Coverage Δ
sentry-ruby/lib/sentry/test_helper.rb 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Ensure enabled_environments contains test environment without mutating
original list.

See: getsentry#2269 (comment)
@ixti ixti force-pushed the ixti/fix-test-setup-helper branch from ebf04a4 to a573841 Compare March 22, 2024 16:04
@st0012
Copy link
Collaborator

st0012 commented Apr 29, 2024

Thanks for the PR, but why did you find it necessary to freeze the enabled_environments array in the first place?

@ixti
Copy link
Author

ixti commented May 2, 2024

My tests were randomly passing randomly failing. Adding a freeze helped to nail down that Sentry helper was changing configuration inplace - thus specs became order-dependent

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.

None yet

2 participants