FyroxEngine/Fyrox · error

Registering empty path.

Error message

Registering empty path.

What it means

ResourceRegistry (the persistent UUID->Path mapping backing the resource registry file) refuses to register an empty path, because an empty path cannot be resolved or reloaded later. register() panics when path.as_os_str().is_empty().

Solutions

  1. Skip empty paths before calling register: only register resources whose path() is Some and non-empty.
  2. Assign a real path to the resource before registry save (or mark it embedded/in-memory so it is not persisted).
  3. Fix path derivation code that produces PathBuf::new() (e.g. .parent() on a bare filename).
  4. When building from memory, use build_from_memory-style APIs that do not require registry paths.

Example fix

// before
registry.register(uuid, resource.path().unwrap_or_default()); // may be empty
// after
if let Some(path) = resource.path() {
    if !path.as_os_str().is_empty() {
        registry.register(uuid, path);
    }
}
Defensive patterns

Strategy: validation

Validate before calling

fn registerable(r: &UntypedResource) -> bool {
    r.path().map_or(false, |p| !p.as_os_str().is_empty())
}

Prevention

When it happens

Trigger: Calling registry.register(uuid, PathBuf::new()) directly, or read_metadata/write_metadata-driven flows that derive paths from resources whose path was never set (e.g. in-memory or programmatically created resources with empty path fields) and then save the registry.

Common situations: Saving a registry that includes resources built from memory (ResourceKind::Embedded / in-memory) that have no file path; stripping a filename incorrectly (Path::new("file.png").parent() yields ""); default-constructed PathBuf passed through.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10). Data as JSON: /api/errors/b29e300c735b3b48. Report an issue: GitHub.

Appendix: source

Thrown at fyrox-resource/src/registry.rs:179

    pub fn remove_metadata(&mut self, path: impl AsRef<Path>) -> Result<(), FileError> {
        if self.unregister_path(&path).is_some() {
            let metadata_path = append_extension(path.as_ref(), ResourceMetadata::EXTENSION);

            self.registry.io.delete_file_sync(&metadata_path)?;

            Ok(())
        } else {
            Err(FileError::Custom(format!(
                "The {:?} resource is not registered in the registry!",
                path.as_ref()
            )))
        }
    }

    /// Registers a new pair `UUID -> Path`, and returns the former path for this UUID.
    pub fn register(&mut self, uuid: Uuid, path: PathBuf) -> RegistryUpdate<Option<PathBuf>> {
        if path.as_os_str().is_empty() {
            panic!("Registering empty path.");
        }
        use std::collections::btree_map::Entry;
        match self.registry.paths.entry(uuid) {
            Entry::Vacant(entry) => {
                info!("Registered: {uuid} -> {path:?}");
                self.changed = true;
                entry.insert(path);
                RegistryUpdate {
                    changed: true,
                    value: None,
                }
            }
            Entry::Occupied(mut entry) => {
                let changed = entry.get() != &path;
                if changed {
                    info!("Registry update: {uuid} -> {path:?}");
                    self.changed = true;
                }

View on GitHub (pinned to 76c91aad8e)