bevy/release-content/migration-guides
Chris Russell 6e918f56d8
Have System::run_unsafe return Result. (#19145)
# Objective

Allow combinator and pipe systems to delay validation of the second
system, while still allowing the second system to be skipped.

Fixes #18796

Allow fallible systems to be used as one-shot systems, reporting errors
to the error handler when used through commands.

Fixes #19722

Allow fallible systems to be used as run conditions, including when used
with combinators. Alternative to #19580.

Always validate parameters when calling the safe
`run_without_applying_deferred`, `run`, and `run_readonly` methods on a
`System`.

## Solution

Have `System::run_unsafe` return a `Result`.  

We want pipe systems to run the first system before validating the
second, since the first system may affect whether the second system has
valid parameters. But if the second system skips then we have no output
value to return! So, pipe systems must return a `Result` that indicates
whether the second system ran.

But if we just make pipe systems have `Out = Result<B::Out>`, then
chaining `a.pipe(b).pipe(c)` becomes difficult. `c` would need to accept
the `Result` from `a.pipe(b)`, which means it would likely need to
return `Result` itself, giving `Result<Result<Out>>`!

Instead, we make *all* systems return a `Result`! We move the handling
of fallible systems from `IntoScheduleConfigs` and `IntoObserverSystem`
to `SystemParamFunction` and `ExclusiveSystemParamFunction`, so that an
infallible system can be wrapped before being passed to a combinator.

As a side effect, this enables fallible systems to be used as run
conditions and one-shot systems.

Now that the safe `run_without_applying_deferred`, `run`, and
`run_readonly` methods return a `Result`, we can have them perform
parameter validation themselves instead of requiring each caller to
remember to call them. `run_unsafe` will continue to not validate
parameters, since it is used in the multi-threaded executor when we want
to validate and run in separate tasks.

Note that this makes type inference a little more brittle. A function
that returns `Result<T>` can be considered either a fallible system
returning `T` or an infallible system returning `Result<T>` (and this is
important to continue supporting `pipe`-based error handling)! So there
are some cases where the output type of a system can no longer be
inferred. It will work fine when directly adding to a schedule, since
then the output type is fixed to `()` (or `bool` for run conditions).
And it will work fine when `pipe`ing to a system with a typed input
parameter.

I used a dedicated `RunSystemError` for the error type instead of plain
`BevyError` so that skipping a system does not box an error or capture a
backtrace.
2025-07-03 21:48:09 +00:00
..
.gitkeep
anchor_is_removed_from_sprite.md Fix Anchor component inconsistancies (#18393) 2025-05-21 15:32:04 +00:00
animation_graph_no_more_asset_ids.md Prevent AnimationGraph from serializing AssetIds. (#19615) 2025-06-30 22:26:05 +00:00
camera_restructure.md Split Camera.hdr out into a new component (#18873) 2025-05-26 19:24:45 +00:00
check_change_ticks.md System::check_change_tick and similar methods take CheckChangeTicks (#19600) 2025-06-13 19:24:27 +00:00
component_entry.md Rename bevy_ecs::world::Entry to ComponentEntry (#19517) 2025-06-10 01:12:40 +00:00
component-lifecycle-module.md Rename Trigger to On (#19596) 2025-06-12 18:22:33 +00:00
composable_specialization.md Composable Pipeline Specialization (#17373) 2025-07-01 01:32:44 +00:00
compressed-image-saver.md add forgotten migration guide (#19800) 2025-06-24 11:19:20 +00:00
convert-coordinates.md Nudge users into migrating to new default glTF coordinate conversion (#19816) 2025-06-28 18:35:41 +00:00
dragenter_includes_dragged_entity.md don't filter dragged entity out of DragEnter events (#19179) 2025-05-26 17:56:54 +00:00
entities_apis.md Remove invalid entity locations (#19433) 2025-05-31 16:34:33 +00:00
entity_cloner_builder_split.md Split EntityClonerBuilder in OptOut and OptIn variants (#19649) 2025-06-24 00:12:08 +00:00
entity_representation.md Fix new typos (#19562) 2025-06-09 22:55:14 +00:00
event_split.md Event Split: Event, EntityEvent, and BufferedEvent (#19647) 2025-06-15 16:46:34 +00:00
fullscreen_shader_resource.md Replace FULLSCREEN_SHADER_HANDLE with a FullscreenShader resource. (#19426) 2025-06-24 00:02:23 +00:00
generic-option-parameter.md
handle_weak_replaced_with_handle_uuid.md Replace Handle::Weak with Handle::Uuid. (#19896) 2025-07-02 14:40:35 +00:00
interned-labels-cleanup.md Remove upcasting methods + Cleanup interned label code (#18984) 2025-05-26 15:38:12 +00:00
labeled_asset_scope_errors.md Allow returning an error from labeled_asset_scope. (#19449) 2025-06-04 00:00:32 +00:00
log-diagnostics-hash-set.md Expose LogDiagnosticsState (#19323) 2025-05-23 20:56:36 +00:00
map_set_apply.md Fix PartialReflect::apply for maps, remove get_at/_mut from Map trait (#19802) 2025-06-25 15:42:01 +00:00
merge_observerState_observer_single_component.md
Newtype_ScrollPosition.md Newtyped ScrollPosition (#19881) 2025-07-01 17:41:48 +00:00
observer_triggers.md Rename Trigger to On (#19596) 2025-06-12 18:22:33 +00:00
observers_may_not_be_exclusive.md
overflowclipbox_default_is_now_paddingbox.md
per-world-error-handler.md Per world error handler (#18810) 2025-05-19 01:35:07 +00:00
picking_location_not_component.md fix(picking): Location is not a Component anymore. (#19306) 2025-05-22 01:33:01 +00:00
pointer_target.md Provide access to the original target of entity-events in observers (#19663) 2025-06-15 20:53:25 +00:00
query_items_borrow_from_query_state.md Remove 's lifetime from WorldQuery::Fetch (#19720) 2025-06-19 00:58:21 +00:00
reflect_asset_asset_ids.md Replace UntypedHandle from ReflectAsset with impl Into<UntypedAssetId>. (#19606) 2025-06-15 16:42:54 +00:00
relationship_set_risky.md EntityWorldMut methods do not automatically overwrite Relationship components (#19601) 2025-06-22 00:22:05 +00:00
relative_cursor_position_is_object_centered.md Fix some typos (#19788) 2025-06-23 22:32:46 +00:00
remove_archetype_component_id.md Remove ArchetypeComponentId and archetype_component_access (#19143) 2025-05-27 19:04:32 +00:00
remove_archetypecomponentid.md
remove_cosmic_text_reexports.md Remove re-exports of cosmic_text types (#19516) 2025-06-06 21:49:02 +00:00
remove_deprecated_batch_spawning.md Fix new typos (#19562) 2025-06-09 22:55:14 +00:00
remove_the_add_sub_impls_on_volume.md fix: Ensure linear volume subtraction does not go below zero (#19423) 2025-06-05 03:59:20 +00:00
rename_condition.md Rename Condition to SystemCondition` (#19328) 2025-05-22 15:50:19 +00:00
rename_pointer_events.md Rename some pointer events and components (#19574) 2025-06-10 21:57:28 +00:00
rename_spawn_gltf_material_name.md Add GltfMeshName component and Deref implementations (#19331) 2025-05-23 20:56:48 +00:00
rename_state_scoped.md Refactor state scoped events to match entities. (#19435) 2025-05-31 20:14:14 +00:00
rename_timer_paused_and_finished.md Rename Timer::finished and Timer::paused to is_finished and is_paused (#19386) 2025-05-27 22:24:18 +00:00
rename_transform_compute_matrix.md rename Transform::compute_matrix to to_matrix (#19646) 2025-06-18 05:37:25 +00:00
rename-justifytext.md Rename JustifyText to Justify (#19522) 2025-06-09 19:59:48 +00:00
render_graph_app_to_ext.md Allow calling add_render_graph_node on World. (#19912) 2025-07-02 14:56:18 +00:00
replace_non_send_resources.md Make GILRS and WINIT_WINDOWS public (#19575) 2025-06-12 20:05:00 +00:00
scalar-field-on-vector-space.md Improve Bevy's double-precision story for third-party crates (#19194) 2025-06-08 02:02:47 +00:00
schedule_slotmaps.md Use SlotMaps to store systems and system sets in Schedules (#19352) 2025-07-03 18:50:54 +00:00
separate-border-colors.md separate border colors (#18682) 2025-05-26 16:57:13 +00:00
simple_executor_going_away.md
specialized_ui_transform.md Specialized UI transform (#16615) 2025-06-09 19:05:49 +00:00
split-window.md Split CursorOptions off of Window (#19668) 2025-06-17 20:20:13 +00:00
stack_z_offsets_changes.md UI z-ordering fix (#19691) 2025-07-01 19:20:07 +00:00
state_scoped_entities_by_default.md Enable state scoped entities by default (#19354) 2025-05-26 20:26:41 +00:00
stop_storing_system_access.md Stop storing access for all systems (#19477) 2025-06-13 17:56:09 +00:00
sync_cell_utils.md refactor(utils): move SyncCell and SyncUnsafeCell to bevy_platform (#19305) 2025-05-27 04:57:26 +00:00
system_run_returns_result.md Have System::run_unsafe return Result. (#19145) 2025-07-03 21:48:09 +00:00
system_set_naming_convention.md
taa_non_experimental.md Make TAA non-experimental, fixes (#18349) 2025-06-02 16:04:08 +00:00
textshadow_is_moved_to_widget_text_module.md Move TextShadow to text widget module (#19579) 2025-06-29 17:37:04 +00:00
unified_system_state_flag.md Unify system state (#19506) 2025-06-08 18:18:43 +00:00
wgpu_25.md Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
zstd.md add native zstd support (#19793) 2025-06-26 20:53:54 +00:00