Tencent/matrix · error · CArcCmdLineException
There is no second file name for rename pair:
Error message
There is no second file name for rename pair:
What it means
When the -snr / rename-pair parsing mode is active (renamePairs != NULL), AddToCensorFromNonSwitchesStrings consumes path arguments in pairs (old name, new name). After the loop, if an odd number of rename arguments was supplied (oldIndex is still set but its partner was never provided), the parser throws "There is no second file name for rename pair:" naming the unmatched first file.
Solutions
- Supply both the old and new file name for each rename pair: 7z rn archive.7z <old_name> <new_name>.
- Check the argument count is even for the rename command before running it.
- Fix scripts so the new-name variable cannot be empty (use ${NEW_NAME:?} style guards).
- If renaming many files, verify each pair in the generated command text.
Example fix
// before 7z rn archive.7z docs/old.txt // after 7z rn archive.7z docs/old.txt docs/new.txt
Defensive patterns
Strategy: validation
Validate before calling
if (renameArgs.length % 2 !== 0 || renameArgs.some(a => !a || a.length === 0)) throw new Error('rename requires an even number of non-empty (old, new) path arguments'); Type guard
const isEvenPairs = (xs) => Array.isArray(xs) && xs.length % 2 === 0 && xs.every(x => typeof x === 'string' && x.length > 0);
Try / catch
try { parser.parse2(argv); } catch (e) { if (String(e.message).startsWith('There is no second file name for rename pair:')) { /* report the unmatched pair name from e.message */ } else throw e; } Prevention
- Always pass rename operations as explicit (old, new) pairs and assert the count is even first.
- Guard the new-name variable against being empty in scripts.
- Echo the generated command line for review before executing batch renames.
- Prefer a wrapper function renamePair(archive, oldName, newName) over raw argument arrays.
When it happens
Trigger: Invoking a rename operation (e.g. 7z rn archive.7z oldname with only one name, or an odd count of positional names) so that the last old-name has no matching new-name, at ArchiveCommandLine.cpp:489 via CArcCmdLineParser::Parse2.
Common situations: Renaming a file inside an archive with 7z rn but forgetting the second argument; a shell variable holding the new name being empty so the pair collapses to one argument; scripted batch renames where an odd element count slips through.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- sdkVersion is absent in result.info.
- manufacturer is absent in result.info.
- hprofEntry is absent in result.info.
- leakedActivityKey is absent in result.info.
- bad extra info line
AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08).
Data as JSON: /api/errors/5b9aa987b07f869e.
Report an issue: GitHub.
Appendix: source
Thrown at matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CPP/7zip/UI/Common/ArchiveCommandLine.cpp:489
else if (renamePairs)
{
if (oldIndex == -1)
oldIndex = i;
else
{
// NRecursedType::EEnum type is used for global wildcard (-i! switches)
AddRenamePair(renamePairs, nonSwitchStrings[oldIndex], s, NRecursedType::kNonRecursed, wildcardMatching);
// AddRenamePair(renamePairs, nonSwitchStrings[oldIndex], s, type);
oldIndex = -1;
}
}
else
AddNameToCensor(censor, s, true, type, wildcardMatching);
}
if (oldIndex != -1)
{
throw CArcCmdLineException("There is no second file name for rename pair:", nonSwitchStrings[oldIndex]);
}
}
#ifdef _WIN32
struct CEventSetEnd
{
UString Name;
CEventSetEnd(const wchar_t *name): Name(name) {}
~CEventSetEnd()
{
NSynchronization::CManualResetEvent event;
if (event.Open(EVENT_MODIFY_STATE, false, GetSystemString(Name)) == 0)
event.Set();
}
};
View on GitHub (pinned to 3b8293bd65)