diem/diem · error

Invalid module name in publish ordering: {}

Error message

Invalid module name in publish ordering: {}

What it means

When publishing with a user-supplied module ordering (e.g. via --override-ordering), publish builds a map of module name → compiled module and then looks up each name from the ordering list. This bail fires when an ordering entry doesn't match any module in the package — the name is misspelled or not part of the current package.

Source

Thrown at language/tools/move-cli/src/sandbox/commands/publish.rs:110

                    let res = session.publish_module(module_bytes, sender, &mut gas_status);
                    if let Err(err) = res {
                        explain_publish_error(err, state, module)?;
                        has_error = true;
                        break;
                    }
                }
            }
            Some(ordering) => {
                let module_map: BTreeMap<_, _> = modules
                    .into_iter()
                    .map(|((ident, _), m)| (ident.value.module.0.value.to_string(), m))
                    .collect();

                let mut sender_opt = None;
                let mut module_bytes_vec = vec![];
                for name in ordering {
                    match module_map.get(name) {
                        None => bail!("Invalid module name in publish ordering: {}", name),
                        Some(module) => {
                            let mut module_bytes = vec![];
                            module.serialize(&mut module_bytes)?;
                            module_bytes_vec.push(module_bytes);
                            if sender_opt.is_none() {
                                sender_opt = Some(*module.self_id().address());
                            }
                        }
                    }
                }

                match sender_opt {
                    None => bail!("No modules to publish"),
                    Some(sender) => {
                        let res = session.publish_module_bundle(
                            module_bytes_vec,
                            sender,
                            &mut gas_status,

View on GitHub (pinned to fc4714a8ea)

Solutions

  1. Correct the ordering entry to exactly match a module in the package (name as it appears in the module map, e.g. `0x42::storage`).
  2. Re-run `move build` and list the package's modules to confirm the exact names, then fix the ordering.
  3. Remove stale entries from publish scripts/ordering files after renaming or deleting modules.

Example fix

// before
$ move sandbox publish --override-ordering 0x42::stoarge build/my_pkg
Invalid module name in publish ordering: 0x42::stoarge

// after (typo fixed)
$ move sandbox publish --override-ordering 0x42::storage build/my_pkg
Defensive patterns

Strategy: validation

Validate before calling

// Validate ordering names against the built module map before publishing
for name in ordering {
    if !module_map.contains_key(name) {
        fatal(format!("unknown module in ordering: {}", name));
    }
}

Prevention

When it happens

Trigger: `move sandbox publish --override-ordering <names...>` where one of the listed names is not a module compiled from the package (typo, wrong address prefix, module removed from sources).

Common situations: Renaming a module in source but keeping the old name in a publish script; ordering lists copied from another package; missing named-address prefix in the ordering entry.

Related errors


AI-assisted analysis of diem/diem@fc4714a8ea (2026-09-04). Data as JSON: /api/errors/42733567ffcf235f. Report an issue: GitHub.