{"record":{"id":"d5f4e5a8295c0630","repo":"tursodatabase/turso","slug":"invalid-config-url-is-required-d5f4e5","errorCode":null,"errorMessage":"invalid config: url is required","messagePattern":"invalid config: url is required","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Serverless.Client/TursoServerlessConnection.cs","lineNumber":51,"sourceCode":"\n    private readonly TursoServerlessConnectionOptions _options;\n    private readonly TursoSession _session;\n    private readonly SemaphoreSlim _execLock = new(1, 1);\n    private bool _isOpen = true;\n\n    public TursoServerlessConnection(TursoServerlessConnectionOptions options)\n        : this(options, SharedHttpClient)\n    {\n    }\n\n    /// <summary>Creates a connection using a caller-provided <see cref=\"HttpClient\"/> (not disposed by this class).</summary>\n    public TursoServerlessConnection(TursoServerlessConnectionOptions options, HttpClient httpClient)\n    {\n        ArgumentNullException.ThrowIfNull(options);\n        ArgumentNullException.ThrowIfNull(httpClient);\n        if (string.IsNullOrEmpty(options.Url))\n        {\n            throw new ArgumentException(\"invalid config: url is required\", nameof(options));\n        }\n\n        _options = options;\n        _session = new TursoSession(options, httpClient);\n    }\n\n    /// <summary>\n    /// Whether the connection is currently inside a transaction, as reported by the server or\n    /// established by a successful cursor transaction-control statement.\n    /// </summary>\n    public bool InTransaction => _session.InTransaction;\n\n    /// <summary>Executes a SQL statement with optional positional arguments and returns the full result set.</summary>\n    public Task<TursoResultSet> ExecuteAsync(string sql, IReadOnlyList<object?>? args = null, TimeSpan? queryTimeout = null, CancellationToken cancellationToken = default)\n    {\n        return LockedExecuteAsync(SqlArgs.ToStatement(sql, args, namedArgs: null, wantRows: true), queryTimeout, cancellationToken);\n    }\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Serverless.Client/TursoServerlessConnection.cs#L33-L69","documentation":"TursoServerlessConnection validates its options before creating a session and requires a non-empty Url. There is no default endpoint, so constructing a connection without a URL fails fast with this ArgumentException rather than at first execute.","triggerScenarios":"new TursoServerlessConnection(new TursoServerlessConnectionOptions()) with Url never assigned; Url populated from an unset environment variable so it binds null or empty string.","commonSituations":"TURSO_DATABASE_URL missing in local .env, CI secrets not injected, or production config binding silently mapping nothing; renaming the env var in one place but not the others.","solutions":["Set options.Url to your database URL (libsql://<db>-<org>.turso.io or the https equivalent) together with AuthToken before constructing the connection","Read the URL from configuration with a startup check: fail loudly when the env var is missing","Add a launch-settings/CI placeholder list of required variables (TURSO_DATABASE_URL, TURSO_AUTH_TOKEN) so omissions surface at deploy time"],"exampleFix":"// before\nvar conn = new TursoServerlessConnection(new TursoServerlessConnectionOptions()); // Url empty\n\n// after\nvar url = Environment.GetEnvironmentVariable(\"TURSO_DATABASE_URL\")\n    ?? throw new InvalidOperationException(\"TURSO_DATABASE_URL is not set\");\nvar conn = new TursoServerlessConnection(new TursoServerlessConnectionOptions { Url = url });","handlingStrategy":"validation","validationCode":"var url = Environment.GetEnvironmentVariable(\"TURSO_DATABASE_URL\");\nif (string.IsNullOrWhiteSpace(url)) throw new InvalidOperationException(\"TURSO_DATABASE_URL is not configured\");","typeGuard":"static bool IsConnectionOptionsValid(TursoServerlessConnectionOptions o) => !string.IsNullOrEmpty(o.Url);","tryCatchPattern":"try { _conn = new TursoServerlessConnection(opts); } catch (ArgumentException ex) when (ex.Message.Contains(\"url is required\")) { throw new InvalidOperationException(\"Database URL missing: set TURSO_DATABASE_URL\", ex); }","preventionTips":["Fail fast at startup on missing env vars instead of at first query","List required env vars in deployment docs and CI secrets checklist","Smoke-test config loading in a health check endpoint"],"tags":["csharp","dotnet","configuration","connection"],"backgroundTag":"missing-connection-url","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}