Skip to content

fix(ClassOption): Return nil if value is not present#3758

Merged
tvdeyen merged 1 commit intomainfrom
fix-class-option
Mar 17, 2026
Merged

fix(ClassOption): Return nil if value is not present#3758
tvdeyen merged 1 commit intomainfrom
fix-class-option

Conversation

@tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Mar 17, 2026

What is this pull request for?

When the class option does not have a default value, it fails with

undefined method 'constantize' for nil (NoMethodError)

Returning nil instead gracefully handles the error.

Fixes an issue with the installer on a fresh Rails app, because we do not have Alchemy.config.user_class default but access it in Alchemy::Engine:150.

Closes #3757

Checklist

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

When the class option does not have a default value,
it fails with

    undefined method 'constantize' for nil (NoMethodError)

Returning `nil` instead gracefully handles the error.

Fixes an issue with the installer on a fresh Rails app,
because we do not have `Alchemy.config.user_class` default
but access it in `Alchemy::Engine`:150.
@tvdeyen tvdeyen requested a review from a team as a code owner March 17, 2026 07:11
@tvdeyen tvdeyen added the backport-to-8.1-stable Needs to be backported to 8.1-stable label Mar 17, 2026
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.46%. Comparing base (8a2e7ae) to head (7ee2131).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3758   +/-   ##
=======================================
  Coverage   97.46%   97.46%           
=======================================
  Files         317      317           
  Lines        8431     8431           
=======================================
  Hits         8217     8217           
  Misses        214      214           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

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

Nice

@tvdeyen tvdeyen merged commit 3397584 into main Mar 17, 2026
28 checks passed
@tvdeyen tvdeyen deleted the fix-class-option branch March 17, 2026 16:14
@alchemycms-bot
Copy link

💚 All backports created successfully

Status Branch Result
8.1-stable

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

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

Labels

backport-to-8.1-stable Needs to be backported to 8.1-stable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing tables: alchemy_elements and alchemy_sites

2 participants