{"record":{"id":"8fd3573af57f764c","repo":"tursodatabase/turso","slug":"parameter-index-index-is-too-large","errorCode":null,"errorMessage":"Parameter index {index} is too large.","messagePattern":"Parameter index (.+?) is too large\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"bindings/dotnet/src/Turso.Raw/Public/TursoBindings.cs","lineNumber":176,"sourceCode":"\n    public static void BindParameter(TursoStatementHandle statement, int index, TursoValue parameter)\n    {\n        statement.ThrowIfInvalid();\n        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(index);\n\n        BindParameterAt(statement, index, parameter);\n    }\n\n    public static int BindNamedParameter(TursoStatementHandle statement, string name, TursoValue parameter)\n    {\n        statement.ThrowIfInvalid();\n        ArgumentNullException.ThrowIfNull(name);\n\n        var index = TursoInterop.StatementNamedPosition(statement, name);\n        if (index < 1)\n            return 0;\n        if (index > int.MaxValue)\n            throw new InvalidOperationException($\"Parameter index {index} is too large.\");\n\n        BindParameterAt(statement, (int)index, parameter);\n        return (int)index;\n    }\n\n    public static bool Read(TursoStatementHandle statement)\n        => Read(statement, runExternalIo: null);\n\n    public static bool Read(TursoStatementHandle statement, Action? runExternalIo)\n    {\n        statement.ThrowIfInvalid();\n\n        while (true)\n        {\n            var status = TursoInterop.StatementStep(statement, out var errorPtr);\n            if (status == TursoStatusCode.Row)\n                return true;\n            if (status == TursoStatusCode.Done)","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Raw/Public/TursoBindings.cs#L158-L194","documentation":"BindNamedParameter resolves a parameter name to its native 1-based position via StatementNamedPosition. Positions below 1 mean the name does not exist and the method silently returns 0 without binding; a position above int.MaxValue instead throws InvalidOperationException. SQLite's variable limit sits orders of magnitude below int.MaxValue, so in practice this throw signals a corrupted or ABI-mismatched native return rather than a realistic parameter count.","triggerScenarios":"A native turso library whose StatementNamedPosition returns a garbage/huge value — typically after mixing bindings and native library versions; hypothetically a generated statement with more than 2^31-1 parameters, which the engine would reject anyway.","commonSituations":"Upgrading the managed NuGet package without shipping the matching native library (or vice versa); custom interop shims changing the position return contract. The far more common gotcha nearby is the silent return-0 path: a typo'd parameter name simply never binds.","solutions":["Verify the named parameter exists before relying on binding: check the return value of BindNamedParameter (0 means the name was not found) and enumerate names with GetParameterName.","Match native library and managed binding versions (same release set) so the position contract holds.","Use positional BindParameter with indexes from GetParameterCount when names are not required.","If it throws with a modest statement, capture SQL and parameter names and report it as a bindings/native mismatch bug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify the name exists before relying on the binding\nint pos = TursoInterop.StatementNamedPosition(statement, name); // or use the BindNamedParameter return value\nif (TursoBindings.BindNamedParameter(statement, name, value) == 0)\n    throw new InvalidOperationException($\"Parameter {name} not found on statement\");","typeGuard":null,"tryCatchPattern":"try { TursoBindings.BindNamedParameter(stmt, name, value); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"too large\")) { /* native/managed version mismatch: realign packages */ }","preventionTips":["Treat a 0 return from BindNamedParameter as a missing-name bug, not success.","Keep native library and managed bindings versions in lockstep.","Prefer positional binding when parameter identity is under your control."],"tags":["dotnet","native-interop","parameter-binding","abi-mismatch"],"backgroundTag":"parameter-index-out-of-range","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}