{"record":{"id":"661f0287be38898b","repo":"Tencent/matrix","slug":"invalidparamexception-661f02","errorCode":null,"errorMessage":"InvalidParamException","messagePattern":"InvalidParamException","errorType":"exception","errorClass":"InvalidParamException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CS/7zip/Compress/LZMA/LzmaEncoder.cs","lineNumber":1378,"sourceCode":"\t\tstatic int FindMatchFinder(string s)\n\t\t{\n\t\t\tfor (int m = 0; m < kMatchFinderIDs.Length; m++)\n\t\t\t\tif (s == kMatchFinderIDs[m])\n\t\t\t\t\treturn m;\n\t\t\treturn -1;\n\t\t}\n\t\n\t\tpublic void SetCoderProperties(CoderPropID[] propIDs, object[] properties)\n\t\t{\n\t\t\tfor (UInt32 i = 0; i < properties.Length; i++)\n\t\t\t{\n\t\t\t\tobject prop = properties[i];\n\t\t\t\tswitch (propIDs[i])\n\t\t\t\t{\n\t\t\t\t\tcase CoderPropID.NumFastBytes:\n\t\t\t\t\t{\n\t\t\t\t\t\tif (!(prop is Int32))\n\t\t\t\t\t\t\tthrow new InvalidParamException();\n\t\t\t\t\t\tInt32 numFastBytes = (Int32)prop;\n\t\t\t\t\t\tif (numFastBytes < 5 || numFastBytes > Base.kMatchMaxLen)\n\t\t\t\t\t\t\tthrow new InvalidParamException();\n\t\t\t\t\t\t_numFastBytes = (UInt32)numFastBytes;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase CoderPropID.Algorithm:\n\t\t\t\t\t{\n\t\t\t\t\t\t/*\n\t\t\t\t\t\tif (!(prop is Int32))\n\t\t\t\t\t\t\tthrow new InvalidParamException();\n\t\t\t\t\t\tInt32 maximize = (Int32)prop;\n\t\t\t\t\t\t_fastMode = (maximize == 0);\n\t\t\t\t\t\t_maxMode = (maximize >= 2);\n\t\t\t\t\t\t*/\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase CoderPropID.MatchFinder:","sourceCodeStart":1360,"sourceCodeEnd":1396,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CS/7zip/Compress/LZMA/LzmaEncoder.cs#L1360-L1396","documentation":"Encoder.SetCoderProperties validates each CoderPropID/property pair. For NumFastBytes it first requires the value be an Int32 and then that it lie within [5, Base.kMatchMaxLen]; a non-int object or an out-of-range fast-bytes value throws InvalidParamException.","triggerScenarios":"Passing propIDs[NumFastBytes] with a value like 4, 0, 300, or a long/string/boxed non-Int32 instead of an int in the properties array.","commonSituations":"Tuning compression by setting NumFastBytes below 5 or above 273 (kMatchMaxLen), or storing the setting as long in config so boxing yields a long, not Int32.","solutions":["Set NumFastBytes to an Int32 within 5..Base.kMatchMaxLen (273), e.g. 32 or 64","Cast/convert config values to int explicitly before building the properties array","Clamp the configured value: Math.Max(5, Math.Min((int)v, 273))"],"exampleFix":"// before\nprops[1] = (long)numFastBytes; // boxed long -> InvalidParamException\n\n// after\nprops[1] = (int)Math.Max(5, Math.Min(numFastBytes, 273));","handlingStrategy":"validation","validationCode":"// C#\nint ClampNumFastBytes(object v) {\n    int n = Convert.ToInt32(v);\n    if (n < 5 || n > 273) throw new ArgumentException(\"NumFastBytes must be in [5, 273]\");\n    return n;\n}","typeGuard":"bool IsValidNumFastBytes(object v) => v is int i && i >= 5 && i <= 273;","tryCatchPattern":"// C#\ntry {\n    encoder.SetCoderProperties(propIDs, props);\n} catch (InvalidParamException ex) {\n    throw new ArgumentException(\"Unsupported LZMA encoder property value\", ex);\n}","preventionTips":["Keep NumFastBytes within 5..273 and as a true Int32","Convert config strings to int explicitly before passing to SetCoderProperties","Add tests covering the encoder property surface with boundary values"],"tags":["csharp","compression","lzma","argument-validation"],"backgroundTag":"value-out-of-range","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"}