Skip to content

fix: replace Invalid_Experiment_Exception with _doing_it_wrong()#303

Merged
dkotter merged 6 commits intodevelopfrom
fix/remove-Invalid_Experiment_Exception
Mar 16, 2026
Merged

fix: replace Invalid_Experiment_Exception with _doing_it_wrong()#303
dkotter merged 6 commits intodevelopfrom
fix/remove-Invalid_Experiment_Exception

Conversation

@justlevine
Copy link
Contributor

@justlevine justlevine commented Mar 13, 2026

What?

This PR removes the Invalid_Experiment_Exception class and replaces it with direct calls to _doing_it_wrong().

Why?

This exception was never outside facing, or triggering. Instead of needing to review or rename it for #234 we might as well remove it alltogether.

image

How?

Use of AI Tools

GitHub Copilot Autocomplete.

Testing Instructions

add_filter( 'ai_experiments_default_experiment_classes', static function( $classes ) {
  $classes[] = 'BadClass';
  return $classes;
);

And confirm other Experiments continue to load, while a _doing_it_wrong() about the bad class is output.

Testing Instructions for Keyboard

Screenshots or screencast

Before After
Open WordPress Playground Preview

@github-actions
Copy link

github-actions bot commented Mar 13, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: justlevine <[email protected]>
Co-authored-by: dkotter <[email protected]>
Co-authored-by: jeffpaul <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.74%. Comparing base (f2b29e6) to head (f37400c).
⚠️ Report is 7 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #303      +/-   ##
=============================================
+ Coverage      58.03%   58.74%   +0.70%     
+ Complexity       576      573       -3     
=============================================
  Files             37       37              
  Lines           2955     2950       -5     
=============================================
+ Hits            1715     1733      +18     
+ Misses          1240     1217      -23     
Flag Coverage Δ
unit 58.74% <100.00%> (+0.70%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@justlevine justlevine self-assigned this Mar 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the internal Invalid_Experiment_Exception and shifts experiment-loading error handling to use _doing_it_wrong() so invalid experiment inputs can be skipped without throwing.

Changes:

  • Removed Invalid_Experiment_Exception class.
  • Updated Experiment_Loader::get_default_experiments() to validate/instantiate filtered experiment entries and report failures via _doing_it_wrong().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
includes/Experiment_Loader.php Replaces exception-based validation with _doing_it_wrong() paths when default experiment classes/instances are invalid.
includes/Exception/Invalid_Experiment_Exception.php Deletes the unused exception type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@jeffpaul jeffpaul requested a review from dkotter March 13, 2026 02:02
@jeffpaul jeffpaul added this to the 0.6.0 milestone Mar 13, 2026
@jeffpaul jeffpaul moved this to Needs review in WordPress AI Planning & Roadmap Mar 13, 2026
dkotter
dkotter previously approved these changes Mar 13, 2026
@justlevine justlevine force-pushed the fix/remove-Invalid_Experiment_Exception branch from 287aa90 to e43105c Compare March 15, 2026 17:31
@justlevine justlevine requested review from dkotter and jeffpaul March 15, 2026 17:33
@dkotter dkotter merged commit 5bbb6db into develop Mar 16, 2026
18 checks passed
@dkotter dkotter deleted the fix/remove-Invalid_Experiment_Exception branch March 16, 2026 14:48
@github-project-automation github-project-automation bot moved this from Needs review to Done in WordPress AI Planning & Roadmap Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants