{"record":{"id":"825043ca789f3d4f","repo":"Tencent/matrix","slug":"kemptyfilepath","errorCode":null,"errorMessage":"kEmptyFilePath","messagePattern":"kEmptyFilePath","errorType":"exception","errorClass":"CArcCmdLineException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CPP/7zip/UI/Common/ArchiveCommandLine.cpp","lineNumber":468,"sourceCode":"    NRecursedType::EEnum type,\n    bool wildcardMatching,\n    bool thereAreSwitchIncludes, Int32 codePage)\n{\n  if ((renamePairs || nonSwitchStrings.Size() == startIndex) && !thereAreSwitchIncludes)\n    AddNameToCensor(censor, UString(kUniversalWildcard), true, type,\n        true // wildcardMatching\n        );\n\n  int oldIndex = -1;\n  \n  if (stopSwitchIndex < 0)\n    stopSwitchIndex = nonSwitchStrings.Size();\n\n  for (unsigned i = startIndex; i < nonSwitchStrings.Size(); i++)\n  {\n    const UString &s = nonSwitchStrings[i];\n    if (s.IsEmpty())\n      throw CArcCmdLineException(kEmptyFilePath);\n    if (i < (unsigned)stopSwitchIndex && s[0] == kFileListID)\n      AddToCensorFromListFile(renamePairs, censor, s.Ptr(1), true, type, wildcardMatching, codePage);\n    else if (renamePairs)\n    {\n      if (oldIndex == -1)\n        oldIndex = i;\n      else\n      {\n        // NRecursedType::EEnum type is used for global wildcard (-i! switches)\n        AddRenamePair(renamePairs, nonSwitchStrings[oldIndex], s, NRecursedType::kNonRecursed, wildcardMatching);\n        // AddRenamePair(renamePairs, nonSwitchStrings[oldIndex], s, type);\n        oldIndex = -1;\n      }\n    }\n    else\n      AddNameToCensor(censor, s, true, type, wildcardMatching);\n  }\n  ","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CPP/7zip/UI/Common/ArchiveCommandLine.cpp#L450-L486","documentation":"AddToCensorFromNonSwitchesStrings builds the list of archive/file path operands from the parsed 7-Zip command line. When one of the non-switch positional strings is an empty string, it throws CArcCmdLineException(kEmptyFilePath) because an empty path is never a valid file/archive operand. This guards downstream code (path censor, archive open) from operating on a meaningless empty path.","triggerScenarios":"Calling CArcCmdLineParser::Parse2 with a positional argument that is an empty UString, e.g. an argv entry that was empty after shell quoting/stripping (like 7z a archive.7z \"\" or a programmatic invocation passing \"\" in the arguments vector) at ArchiveCommandLine.cpp:468.","commonSituations":"Shell quoting errors that yield an empty argument (7z a out.7z \"$UNSET_VAR\"); scripts that join a path variable with a separator producing an empty element; programmatic/embedded usage of the 7-Zip library where an args array contains an empty string; trimming a path to empty before invoking the command line parser.","solutions":["Find the positional argument that expands to an empty string (e.g. an unset shell variable or empty array element) and remove or populate it.","Quote variables correctly in shell scripts and use ${VAR:?} to abort when a path variable is empty.","Filter empty strings out of the argument vector before calling the parser programmatically.","Validate all file/archive path arguments are non-empty before invoking the 7z command."],"exampleFix":"// before (shell)\n7z a out.7z \"$SRC_PATH\"\n// after\n: \"${SRC_PATH:?SRC_PATH must be set}\"\n7z a out.7z \"$SRC_PATH\"","handlingStrategy":"validation","validationCode":"args.forEach((a, i) => { if (typeof a !== 'string' || a.trim() === '') throw new Error(`7z argument ${i} must be a non-empty path`); });","typeGuard":"const isNonEmptyPath = (a) => typeof a === 'string' && a.trim().length > 0;","tryCatchPattern":"try { parser.parse2(args); } catch (e) { if (String(e.message).includes('kEmptyFilePath')) { /* drop empty positional args and retry */ } else throw e; }","preventionTips":["Never pass raw, unfiltered shell variables as positional path arguments.","Use ${VAR:?} shell guards to abort when a path variable is empty.","Filter the argument array for empty/whitespace-only strings before invoking the parser.","Log the full argv when a parse error occurs to spot empty entries quickly."],"tags":["cli","empty-argument","command-line-parsing"],"backgroundTag":"empty-required-field","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}