Skip to content

Move setting Spree.root_domain earlier in the chain#1

Merged
damianlegawiec merged 1 commit into
mainfrom
fix/root-domain-initializer-fix
Mar 31, 2026
Merged

Move setting Spree.root_domain earlier in the chain#1
damianlegawiec merged 1 commit into
mainfrom
fix/root-domain-initializer-fix

Conversation

@damianlegawiec
Copy link
Copy Markdown
Member

@damianlegawiec damianlegawiec commented Mar 31, 2026

Summary by CodeRabbit

  • Chores
    • Adjusted initialization timing for root domain configuration to load earlier during application startup.

@github-actions
Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

Walkthrough

The Spree.root_domain assignment was relocated from within the Rails.application.config.after_initialize block to the top-level of the initializer file. The value remains sourced from the SPREE_ROOT_DOMAIN environment variable with 'localhost' as the default, now executing earlier during Rails initialization.

Changes

Cohort / File(s) Summary
Root Domain Initialization
config/initializers/spree_multi_store.rb
Moved Spree.root_domain assignment from within after_initialize block to top-level scope, changing when during Rails boot this configuration is applied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hopping through initialization's timeline,
We shuffle the sequence to make boots align—
Root domain now leaps earlier in the race,
A sprint to the finish with better grace.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: moving the Spree.root_domain initialization earlier in the initialization chain.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/root-domain-initializer-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
config/initializers/spree_multi_store.rb (1)

4-4: Consider handling blank SPREE_ROOT_DOMAIN as fallback to default.

If SPREE_ROOT_DOMAIN is present but empty, ENV.fetch returns "" instead of "localhost", which can silently disable auto URL generation.

Suggested tweak
-Spree.root_domain = ENV.fetch('SPREE_ROOT_DOMAIN', 'localhost')
+Spree.root_domain = ENV['SPREE_ROOT_DOMAIN'].presence || 'localhost'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/initializers/spree_multi_store.rb` at line 4, The current assignment
to Spree.root_domain uses ENV.fetch('SPREE_ROOT_DOMAIN', 'localhost') which
treats an explicit empty string as a valid value; change it to treat
blank/whitespace-only values as missing by reading ENV['SPREE_ROOT_DOMAIN'] (or
ENV.fetch with empty default), trim it, and fall back to 'localhost' when the
result is empty so Spree.root_domain is never set to an empty string; update the
code around the Spree.root_domain assignment to implement this blank-aware
fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@config/initializers/spree_multi_store.rb`:
- Line 4: The current assignment to Spree.root_domain uses
ENV.fetch('SPREE_ROOT_DOMAIN', 'localhost') which treats an explicit empty
string as a valid value; change it to treat blank/whitespace-only values as
missing by reading ENV['SPREE_ROOT_DOMAIN'] (or ENV.fetch with empty default),
trim it, and fall back to 'localhost' when the result is empty so
Spree.root_domain is never set to an empty string; update the code around the
Spree.root_domain assignment to implement this blank-aware fallback.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5e03a13a-8e0a-4dab-b452-1412ab5a150f

📥 Commits

Reviewing files that changed from the base of the PR and between 5758a91 and 7c6d4c7.

📒 Files selected for processing (1)
  • config/initializers/spree_multi_store.rb

@damianlegawiec damianlegawiec merged commit 143d396 into main Mar 31, 2026
5 of 6 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2026
@damianlegawiec damianlegawiec deleted the fix/root-domain-initializer-fix branch April 23, 2026 12:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant