jdx/mise · error

unsupported encrypted file mode

Error message

unsupported encrypted file mode: {path}

What it means

Thrown by `encode` when the file mode of a file being encrypted is not one of the supported git file modes: regular file (100644), executable file (100755), or symlink (120000). Modes like 160000 (git submodule/gitlink) or 040000 (tree) cannot be represented in an encrypted plaintext envelope.

Solutions

  1. Exclude submodule paths from the encryption list.
  2. Encrypt individual files inside the submodule's target location instead of the submodule link.
  3. Replace the submodule with a plain directory of files if it should be synced.

Example fix

// before (pattern matches submodule)
encrypt = ["~/dotfiles/**"]
// after
encrypt = ["~/dotfiles/**", "!~/dotfiles/vendor"]
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_MODES = ["100644", "100755", "120000"];
if (!SUPPORTED_MODES.includes(mode)) {
  throw new Error(`unsupported mode ${mode} for ${path}`);
}
await sync.encrypt(path, mode, content);

Type guard

function hasSupportedMode(mode: string): boolean {
  return ["100644", "100755", "120000"].includes(mode);
}

Try / catch

try {
  await sync.encrypt(path, mode, content);
} catch (e) {
  if (/unsupported encrypted file mode/.test(String(e))) {
    log.warn(`skipping ${path}: mode ${mode} not encryptable`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `encode` (via `encrypt`) with a `mode` argument other than "100644", "100755", or "120000" — e.g. encrypting a git submodule entry or a directory entry.

Common situations: A dotfiles repo contains git submodules; a sync pattern accidentally picks up a submodule path; directory entries passed to encrypt instead of individual files.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/62a2b82db8d00af1. Report an issue: GitHub.

Appendix: source

Thrown at src/system/history/sync/files.rs:345

        })
        .collect::<Result<Vec<_>>>()?;
    encrypt(repo, path, object, &scheme, &recipients)
}

/// Encrypt bytes before they enter Git. Callers may store only the returned
/// envelope, never the input or the decrypted payload in repository objects.
pub(crate) fn encode(
    path: &str,
    mode: &str,
    content: &[u8],
    scheme: &str,
    recipients: &[Box<dyn age::Recipient + Send>],
) -> Result<Vec<u8>> {
    if control_file(path) {
        bail!("encrypt an external dotfile source instead of configuration: {path}");
    }
    if !matches!(mode, "100644" | "100755" | "120000") {
        bail!("unsupported encrypted file mode: {path}");
    }
    let inner = Plaintext {
        path: path.into(),
        mode: mode.into(),
        scheme: scheme.into(),
        content: Bytes(content.to_vec()),
    };
    let bytes = rmp_serde::to_vec_named(&inner)?;
    let outer = Envelope {
        path: path.into(),
        mode: mode.into(),
        scheme: scheme.into(),
        ciphertext: Bytes(agecrypt::encrypt_bytes(&bytes, recipients)?),
    };
    let mut encoded = MAGIC.to_vec();
    encoded.extend(rmp_serde::to_vec_named(&outer)?);
    if encoded.len() as u64 > agecrypt::MAX_ENCRYPTED_BYTES {
        bail!("encrypted file exceeds the size limit: {path}");

View on GitHub (pinned to 533346cc37)