Skip to content

fix: eagerly load configuration.rb to fix WorkOS.configure#467

Merged
gjtorikian merged 2 commits intomainfrom
fix-configuration-autoload
Apr 27, 2026
Merged

fix: eagerly load configuration.rb to fix WorkOS.configure#467
gjtorikian merged 2 commits intomainfrom
fix-configuration-autoload

Conversation

@gjtorikian
Copy link
Copy Markdown
Contributor

Summary

  • Adds configuration.rb to the list of hand-maintained files ignored by Zeitwerk and explicitly required
  • Follows the same pattern already used for errors.rb and inflections.rb
  • Zeitwerk only autoloads on constant access, not method calls — so WorkOS.configure was unavailable until something happened to reference WorkOS::Configuration first

Fixes #462

Test plan

  • Confirm WorkOS.configure { |c| ... } works immediately after require 'workos' without needing an explicit require 'workos/configuration'

🤖 Generated with Claude Code

Zeitwerk only triggers autoloading on constant access, not method calls.
WorkOS.configure is defined in the hand-maintained configuration.rb, so it
must be explicitly required — same pattern already used for errors.rb.

Fixes #462

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gjtorikian gjtorikian requested review from a team as code owners April 27, 2026 20:58
@gjtorikian gjtorikian requested a review from blairworkos April 27, 2026 20:58
configuration.rb is now eagerly loaded, so the explicit
require "workos/configuration" workaround is no longer needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gjtorikian gjtorikian merged commit eea391c into main Apr 27, 2026
7 checks passed
@gjtorikian gjtorikian deleted the fix-configuration-autoload branch April 27, 2026 21:00
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR fixes a bug where WorkOS.configure was unavailable immediately after require 'workos' because Zeitwerk only autoloads constants on first access, not method calls. The fix adds configuration.rb to Zeitwerk's ignore list and eagerly requires it — mirroring the existing pattern for errors.rb and inflections.rb — and removes the now-unnecessary explicit require "workos/configuration" from the README initializer example.

Confidence Score: 5/5

Safe to merge — targeted, low-risk fix that follows an established pattern in the codebase.

The change is minimal (two lines in lib/workos.rb, one line removed from README), directly mirrors the existing pattern for errors.rb and inflections.rb, and correctly addresses the root cause of the Zeitwerk autoload timing issue.

No files require special attention.

Important Files Changed

Filename Overview
lib/workos.rb Adds loader.ignore + eager require for configuration.rb, consistent with existing errors.rb and inflections.rb pattern
README.md Removes now-unnecessary explicit require "workos/configuration" from initializer example
.oagen-manifest.json Timestamp-only update reflecting oagen regeneration — no substantive change

Sequence Diagram

sequenceDiagram
    participant App
    participant workos_rb as lib/workos.rb
    participant Zeitwerk
    participant configuration_rb as workos/configuration.rb

    Note over App,configuration_rb: Before fix
    App->>workos_rb: require "workos"
    workos_rb->>Zeitwerk: loader.setup
    App->>App: WorkOS.configure { ... }
    Note right of App: ❌ NoMethodError — configuration.rb not yet loaded

    Note over App,configuration_rb: After fix
    App->>workos_rb: require "workos"
    workos_rb->>Zeitwerk: loader.ignore(configuration.rb)
    workos_rb->>Zeitwerk: loader.setup
    workos_rb->>configuration_rb: require "workos/configuration" (eager)
    configuration_rb-->>workos_rb: WorkOS::Configuration + WorkOS.configure defined
    App->>App: WorkOS.configure { ... }
    Note right of App: ✅ Works immediately
Loading

Reviews (1): Last reviewed commit: "docs: remove unnecessary require from RE..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

v7 configuration error

1 participant