Skip to content

Conversation

@mrchantey
Copy link
Contributor

The new 0.18 entity errors feel a bit 'inside baseball' for end-users, for instance interacting with a despawned entity makes no mention of the entity not being spawned:

let mut world = World::new();
let entity = world.spawn_empty().id();
world.entity_mut(entity).despawn();
world.entity(entity);

// Panic: The entity with ID 27v0 is invalid; its index now has generation 1.

Ideally I'd like to implement proper rust-style errors with a short paragraph detailing common causes and links to docs but thats a bigger discussion.

At least for 0.18 i think this very common error needs a prefix Entity Not Spawned:

  • Before: The entity with ID 27v0 is invalid; its index now has generation 1.
  • After: Entity Not Spawned: The entity with ID 27v0 is invalid; its index now has generation 1.

@mrchantey mrchantey added D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Jan 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-22444

If it's expected, please add the M-Deliberate-Rendering-Change label.

If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it.

Copy link
Contributor

@ElliottjPierce ElliottjPierce left a comment

Choose a reason for hiding this comment

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

First of all, as far as I'm concerned, this is an aesthetic change, and I'll be the first to admit that my error messages may not be friendly to new users. Probably just been using these terms to understand it myself, and sometimes I forget that not everyone (especially those not obsessed with the internals of entities) thinks in the same terms.

So, I'm happy with anything here. Usually you guys have better naming ideas than me anyway.


With that said, here's some feedback: The EntityNotSpawnedError::Invalid rarely means the entity was not spawned. For that to happen, a made up Entity would need to be used which has not yet been spawned. The error in this pr's example, is not that the entity had not been spawned, but that it had been despawned since.

We should also consider helping out EntityNotSpawnedError::ValidButNotSpawned. This can happen because of entity generation wrapping, but it is more commonly caused when an entity has been allocated/reserved but not fully initialized yet.

So, my suggestion for the error prefix might be more like:
"Entity despawned: " for Invalid and "Entity not yet spawned: " for ValidButNotSpawned. But neither prefix covers all the possible causes–just the most common.

Either way, more docs here would certainly be good. Maybe this is something for the bevy error people to look at? I haven't been keeping up with that, but IIRC, there was a team working on adding links and docs around common errors.

@mrchantey mrchantey added the M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered label Jan 9, 2026
@mrchantey
Copy link
Contributor Author

awesome thanks for that context, here's the updated version

Invalid:
"Entity despawned: {0}\nNote that interacting with a despawned entity is the most common cause of this error but there are others"
ValidButNotSpawned:
"Entity not yet spawned: {0}\nNote that interacting with a not-yet-spawned entity is the most common cause of this error but there are others"

Copy link
Contributor

@ElliottjPierce ElliottjPierce left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@mrchantey mrchantey added this to the 0.18 milestone Jan 10, 2026
@ChristopherBiscardi ChristopherBiscardi added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed M-Deliberate-Rendering-Change An intentional change to how tests and examples are rendered labels Jan 10, 2026
@ChristopherBiscardi ChristopherBiscardi added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 10, 2026
@ChristopherBiscardi
Copy link
Contributor

PR targets the release branch, so the visual diff comment is because it's diffing from "main's version" to the release version and not because there are real changes.

@alice-i-cecile alice-i-cecile changed the base branch from release-0.18.0 to main January 10, 2026 06:55
@alice-i-cecile alice-i-cecile changed the base branch from main to release-0.18.0 January 10, 2026 06:56
@alice-i-cecile alice-i-cecile removed this from the 0.18 milestone Jan 10, 2026
@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Jan 10, 2026
@alice-i-cecile
Copy link
Member

This is targeting the wrong branch: it needs to target main, then get cherrypicked on.

I tried swapping this with the Github UI, but the diff got messed up. Take a look, and remake the PR if it starts to be a headache.

If this is merged in time we'll ship it with 0.18 :)

@mrchantey mrchantey changed the base branch from release-0.18.0 to main January 10, 2026 10:34
@mrchantey mrchantey changed the base branch from main to release-0.18.0 January 10, 2026 10:35
@mrchantey
Copy link
Contributor Author

closing in favor of same pr on main branch #22467

@mrchantey mrchantey closed this Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants