nilaoda/N_m3u8DL-RE · error · ArgumentException

Parse Argument [ ] failed!

Error message

Parse Argument [{key}] failed!

What it means

ComplexParamParser.GetValue looks up a key in the parsed complex-parameter string and throws ArgumentException("Parse Argument [{key}] failed!") when the internal parsing/formatting of the value fails for any reason (the original exception is discarded). Callers use it to extract values from options like headers or custom params.

Solutions

  1. Escape or remove unbalanced apostrophes/double quotes in the value.
  2. Ensure each pair is in key=value form separated by the expected delimiter.
  3. Print the raw input string and check it manually for stray characters.
  4. Wrap GetValue in try/catch and fall back to the raw string if parsing fails.

Example fix

// before
var v = parser.GetValue("header"); // throws on malformed input
// after
try { var v = parser.GetValue("header"); }
catch (ArgumentException) { /* use raw fallback */ }
Defensive patterns

Strategy: try-catch

Validate before calling

if (string.IsNullOrWhiteSpace(input) || !input.Contains('=')) throw new FormatException("Complex param must contain key=value pairs");

Type guard

bool LooksParseable(string s) => s.Split(',').All(p => p.Split('=').Length == 2);

Try / catch

try { value = parser.GetValue(key); }
catch (ArgumentException) { value = rawFallback; }

Prevention

When it happens

Trigger: Calling GetValue(key) on an input string whose structure the parser cannot handle — unbalanced quotes/apostrophes, malformed key=value pairs, or a key whose value block fails parsing — any internal exception is wrapped into this error.

Common situations: Users pass header/param strings with unescaped apostrophes or double quotes (e.g. "It's here" or nested quotes), or omit the '=' separator, when configuring headers or muxer options.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of nilaoda/N_m3u8DL-RE@e113dee70c (2026-09-13). Data as JSON: /api/errors/f9fa60072e4dc1e7. Report an issue: GitHub.

Appendix: source

Thrown at src/N_m3u8DL-RE/CommandLine/ComplexParamParser.cs:58

                    result.Append(chars[i]);
                }
            }

            var resultStr = result.ToString().Trim();

            // 仅去除成对的首尾引号, 保留值内部的引号(例如文件名中的撇号: What's Next)
            if (resultStr.Length >= 2
                && (resultStr[0] == '\"' || resultStr[0] == '\'')
                && resultStr[^1] == resultStr[0])
            {
                resultStr = resultStr[1..^1];
            }

            return resultStr;
        }
        catch (Exception)
        {
            throw new ArgumentException($"Parse Argument [{key}] failed!");
        }
    }
}

View on GitHub (pinned to e113dee70c)