You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent experiments from getting stuck in pending on empty datasets (#14031)
Experiments triggered on datasets with zero items would silently fail,
leaving the experiment record stuck in "pending" status forever. The
fire-and-forget `.catch(() => {})` swallowed the error from
`runExperiment()` before it could update the status.
Three-layer fix:
**Core** — `startExperimentAsync` now validates item count before
creating the experiment record. Throws `EXPERIMENT_NO_ITEMS` on empty
datasets. The catch handler marks experiments as `failed` and logs the
error instead of silently discarding.
**Server** — Maps `EXPERIMENT_NO_ITEMS` to HTTP 400. Returns actual
`totalItems` from experiment instead of hardcoded `0`.
**UI** — Disables the Run Experiment button with a tooltip when dataset
has no items.
Also added test coverage for the empty dataset paths in both
`dataset.test.ts` and `runExperiment.test.ts`.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Triggering an experiment on an empty dataset now errors immediately
(HTTP 400) instead of staying pending.
* Setup failures for async experiments are logged and mark the
experiment as failed.
* Experiment responses now report an accurate totalItems count.
* **New Features**
* Run Experiment button is disabled for empty datasets with a tooltip:
"Add items to the dataset before running an experiment".
* UI checks the unfiltered dataset so searches won't incorrectly disable
the trigger.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: YJ <yj@example.com>
Co-authored-by: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
Experiments now fail immediately with a clear error when triggered on a dataset with zero items, instead of getting stuck in "pending" status forever. The experiment trigger API returns HTTP 400 for empty datasets. Unexpected errors during async experiment setup are now logged and mark the experiment as failed.
0 commit comments