{"record":{"id":"62a2b82db8d00af1","repo":"jdx/mise","slug":"unsupported-encrypted-file-mode-path","errorCode":null,"errorMessage":"unsupported encrypted file mode: {path}","messagePattern":"unsupported encrypted file mode: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/sync/files.rs","lineNumber":345,"sourceCode":"        })\n        .collect::<Result<Vec<_>>>()?;\n    encrypt(repo, path, object, &scheme, &recipients)\n}\n\n/// Encrypt bytes before they enter Git. Callers may store only the returned\n/// envelope, never the input or the decrypted payload in repository objects.\npub(crate) fn encode(\n    path: &str,\n    mode: &str,\n    content: &[u8],\n    scheme: &str,\n    recipients: &[Box<dyn age::Recipient + Send>],\n) -> Result<Vec<u8>> {\n    if control_file(path) {\n        bail!(\"encrypt an external dotfile source instead of configuration: {path}\");\n    }\n    if !matches!(mode, \"100644\" | \"100755\" | \"120000\") {\n        bail!(\"unsupported encrypted file mode: {path}\");\n    }\n    let inner = Plaintext {\n        path: path.into(),\n        mode: mode.into(),\n        scheme: scheme.into(),\n        content: Bytes(content.to_vec()),\n    };\n    let bytes = rmp_serde::to_vec_named(&inner)?;\n    let outer = Envelope {\n        path: path.into(),\n        mode: mode.into(),\n        scheme: scheme.into(),\n        ciphertext: Bytes(agecrypt::encrypt_bytes(&bytes, recipients)?),\n    };\n    let mut encoded = MAGIC.to_vec();\n    encoded.extend(rmp_serde::to_vec_named(&outer)?);\n    if encoded.len() as u64 > agecrypt::MAX_ENCRYPTED_BYTES {\n        bail!(\"encrypted file exceeds the size limit: {path}\");","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/sync/files.rs#L327-L363","documentation":"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.","triggerScenarios":"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.","commonSituations":"A dotfiles repo contains git submodules; a sync pattern accidentally picks up a submodule path; directory entries passed to encrypt instead of individual files.","solutions":["Exclude submodule paths from the encryption list.","Encrypt individual files inside the submodule's target location instead of the submodule link.","Replace the submodule with a plain directory of files if it should be synced."],"exampleFix":"// before (pattern matches submodule)\nencrypt = [\"~/dotfiles/**\"]\n// after\nencrypt = [\"~/dotfiles/**\", \"!~/dotfiles/vendor\"]","handlingStrategy":"validation","validationCode":"const SUPPORTED_MODES = [\"100644\", \"100755\", \"120000\"];\nif (!SUPPORTED_MODES.includes(mode)) {\n  throw new Error(`unsupported mode ${mode} for ${path}`);\n}\nawait sync.encrypt(path, mode, content);","typeGuard":"function hasSupportedMode(mode: string): boolean {\n  return [\"100644\", \"100755\", \"120000\"].includes(mode);\n}","tryCatchPattern":"try {\n  await sync.encrypt(path, mode, content);\n} catch (e) {\n  if (/unsupported encrypted file mode/.test(String(e))) {\n    log.warn(`skipping ${path}: mode ${mode} not encryptable`);\n  } else throw e;\n}","preventionTips":["Exclude submodule (160000) and directory (040000) entries from encryption.","Encrypt files, not trees or submodule links.","Check `git ls-files -s` modes before adding paths to encryption."],"tags":["encryption","file-mode","unsupported"],"backgroundTag":"unsupported-enum-value","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}