Skip to content

fix: skip connects_to during eager load when SolidApm is disabled - #22

Merged
Bhacaz merged 2 commits into
mainfrom
copilot/fix-solid-apm-test-configuration
Apr 3, 2026
Merged

Bhacaz merged 2 commits into
mainfrom
copilot/fix-solid-apm-test-configuration

Conversation

Copilot AI commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

With eager_load: true (e.g. CI=1), Zeitwerk loads SolidApm::ApplicationRecord at boot time. The unconditional connects_to call fails with ActiveRecord::AdapterNotSpecified in environments (like test) that don't have a solid_apm database configured — even though the Railtie correctly sets SolidApm.enabled = false before initialization.

Change

  • app/models/solid_apm/application_record.rb: Guard connects_to so it only runs when SolidApm is enabled and a database connection is actually configured.
# Before
self.connects_to **SolidApm.connects_to

# After
connects_to(**SolidApm.connects_to) if SolidApm.enabled && SolidApm.connects_to.present?

No database.yml solid_apm entry is required in test — consistent with the documented behavior that SolidApm is automatically disabled in the test environment.

@Bhacaz
Bhacaz marked this pull request as ready for review April 3, 2026 13:51
@Bhacaz
Bhacaz merged commit 124e650 into main Apr 3, 2026
1 check passed
@Bhacaz
Bhacaz deleted the copilot/fix-solid-apm-test-configuration branch April 3, 2026 13:52
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