tursodatabase/turso · error · ArgumentException
Parameter {value} not found
Error message
Parameter {value} not found What it means
TursoParameterCollection.Remove(object) throws this ArgumentException when the value cannot be found in the collection (IndexOf returns -1). Lookup is by the stored TursoParameter instances/names, so removing a freshly constructed parameter that merely looks equal, or passing a raw string name, will not match.
Source
Thrown at bindings/dotnet/src/Turso.Data/TursoParameterCollection.cs:82
{
return _parameters.FindIndex(p => value is TursoParameter ? p == value : p.Value == value);
}
public override int IndexOf(string parameterName)
{
return _parameters.FindIndex(p => p.ParameterName == parameterName);
}
public override void Insert(int index, object value)
{
_parameters.Insert(index, value as TursoParameter ?? new TursoParameter(value));
}
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)View on GitHub (pinned to 244cde92a7)
Solutions
- Remove by name instead: cmd.Parameters.RemoveAt("@id").
- Or keep and pass the exact instance you added when using Remove(instance).
- Check cmd.Parameters.IndexOf(name) != -1 (or Contains) before removing in conditional cleanup code.
Example fix
// before
cmd.Parameters.Remove(new TursoParameter("@id", 1)); // new instance -> not found
// after
cmd.Parameters.RemoveAt("@id"); Defensive patterns
Strategy: validation
Validate before calling
if (cmd.Parameters.IndexOf(parameter.ParameterName) != -1)
cmd.Parameters.Remove(parameter); Prevention
- Prefer RemoveAt(name) over Remove(instance) unless you hold the exact added instance.
- Never construct a look-alike parameter just to remove it.
When it happens
Trigger: Calling cmd.Parameters.Remove(new TursoParameter("@id", 1)) instead of removing the instance that was added; calling Remove(someString) expecting name-based removal; removing a parameter that was already removed or belongs to a different command.
Common situations: Helper methods that rebuild parameters to remove them; retry loops that clear/re-add parameters and then remove stale references; mixing up Remove(object) with RemoveAt(string) from other collection APIs.
Related errors
- Parameter {parameterName} not found
- Parameter {value} is not a TursoParameter
- Only input parameters are supported
- Parameter type {valueType} is not supported
- Embedded replica sync is not supported yet by the .NET provi
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/5620e195a6dfa2ef.
Report an issue: GitHub.