Tencent/matrix · error · CArcCmdLineException

errorMessage

Error message

errorMessage

What it means

While parsing an update command string (the switch value passed with -u, e.g. -u0/-u1 style state:action pairs), ParseUpdateCommandString encountered an unparseable element; the generic errorMessage variable holds the specific reason (e.g. "Too short switch", "Incorrect update switch command", unknown action) and the parser throws it together with the offending updatePostStrings[i] at ArchiveCommandLine.cpp:726.

Solutions

  1. Use only the documented pair-state letters (p q r x y z w) followed by a valid action index (0-3) in the -u switch.
  2. Check the exact offending string echoed in the exception message and correct its syntax/length.
  3. Consult the 7-Zip -u switch documentation for the version in use, as supported actions differ between versions.
  4. When composing -u strings in code, build them from a whitelist of valid state/action characters.

Example fix

// before
7z u archive.7z -uq9
// after
7z u archive.7z -uq0
Defensive patterns

Strategy: validation

Validate before calling

const VALID = /^[pqxyzw][0-3](?:![^\s]*)?$/; for (const u of updateSwitchValues) { if (!VALID.test(u)) throw new Error(`invalid -u update switch value: ${u}`); }

Type guard

const isValidUpdateSwitch = (u) => typeof u === 'string' && /^[pqxyzw][0-3]/.test(u);

Try / catch

try { parser.parse2(argv); } catch (e) { if (String(e.message).includes('switch')) { /* re-read the offending -u value named in the exception */ } else throw e; }

Prevention

When it happens

Trigger: Calling CArcCmdLineParser::Parse2 on an update command whose -u switch value cannot be parsed by ParseUpdateCommandString2: an action character outside p/q/r/x/y/z/w, a string shorter than the required marker+action length, or an invalid '!' new-archive spec after the action.

Common situations: Hand-writing update switches like -uq0 with a typo; copying documented -u syntax from incompatible 7-Zip versions; programmatically composing update action sets with an invalid state/action character.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/3ee68bb47b664439. 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:726

        if (options.UpdateArchiveItself)
          options.Commands[0].ActionSet = actionSet;
      }
      else
      {
        if (postString[0] != kUpdateNewArchivePostCharID)
          break;
        CUpdateArchiveCommand uc;
        UString archivePath = postString.Ptr(1);
        if (archivePath.IsEmpty())
          break;
        uc.UserArchivePath = archivePath;
        uc.ActionSet = actionSet;
        options.Commands.Add(uc);
      }
    }
  }
  if (i != updatePostStrings.Size())
    throw CArcCmdLineException(errorMessage, updatePostStrings[i]);
}

bool ParseComplexSize(const wchar_t *s, UInt64 &result);

static void SetAddCommandOptions(
    NCommandType::EEnum commandType,
    const CParser &parser,
    CUpdateOptions &options)
{
  NUpdateArchive::CActionSet defaultActionSet;
  switch (commandType)
  {
    case NCommandType::kAdd:
      defaultActionSet = NUpdateArchive::k_ActionSet_Add;
      break;
    case NCommandType::kDelete:
      defaultActionSet = NUpdateArchive::k_ActionSet_Delete;
      break;

View on GitHub (pinned to 3b8293bd65)