tursodatabase/turso · error · ArgumentException

Parameter {parameterName} not found

Error message

Parameter {parameterName} not found

What it means

TursoParameterCollection.RemoveAt(string parameterName) throws this ArgumentException when no parameter's ParameterName equals the given name. Matching is exact string equality ('=='), so it is case-sensitive and prefix-sensitive: removing "id" when the parameter was added as "@id" fails.

Source

Thrown at bindings/dotnet/src/Turso.Data/TursoParameterCollection.cs:95

    public override void Remove(object value)
    {
        var index = IndexOf(value);
        if (index == -1)
            throw new ArgumentException($"Parameter {value} not found");
        _parameters.RemoveAt(index);
    }

    public override void RemoveAt(int index)
    {
        _parameters.RemoveAt(index);
    }

    public override void RemoveAt(string parameterName)
    {
        var index = IndexOf(parameterName);
        if (index == -1)
            throw new ArgumentException($"Parameter {parameterName} not found");

        _parameters.RemoveAt(index);
    }

    protected override DbParameter GetParameter(int index)
    {
        return _parameters[index];
    }

    protected override DbParameter GetParameter(string parameterName)
    {
        return _parameters.Find(p => p.ParameterName == parameterName)
               ?? throw new ArgumentException($"Parameter {parameterName} not found");
    }

    protected override void SetParameter(int index, DbParameter value)
    {
        _parameters[index] = value as TursoParameter

View on GitHub (pinned to 244cde92a7)

Solutions

  1. Use the exact name the parameter was added with, including the '@' prefix and casing.
  2. Standardize one naming convention (e.g. always '@name') across add/remove sites.
  3. Guard removals with 'if (cmd.Parameters.IndexOf(name) != -1)' or Contains-style checks.

Example fix

// before
cmd.Parameters.Add(new TursoParameter("@id", 1));
cmd.Parameters.RemoveAt("id"); // name mismatch

// after
cmd.Parameters.RemoveAt("@id");
Defensive patterns

Strategy: validation

Validate before calling

if (cmd.Parameters.IndexOf("@id") is var i && i != -1)
    cmd.Parameters.RemoveAt(i);

Prevention

When it happens

Trigger: Calling RemoveAt("id") for a parameter stored as "@id" (or the reverse); case mismatches like RemoveAt("@ID") vs added "@id"; removing a parameter twice; removing from the wrong command's collection.

Common situations: Inconsistent @-prefix conventions between the code that adds parameters and the code that removes them; refactoring that renamed parameters on one side only; copy-pasted cleanup code between commands with different parameter names.

Related errors


AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20). Data as JSON: /api/errors/9a1b9952b88a990c. Report an issue: GitHub.