tursodatabase/turso · error · ArgumentException

The sync remote URL must be absolute.

Error message

The sync remote URL must be absolute.

What it means

GetNormalizedRemoteUri validates the configured RemoteUri before constructing the sync database. A relative URI has no scheme/host to build HTTP requests against, so it throws ArgumentException('The sync remote URL must be absolute.', nameof(RemoteUri)).

Source

Thrown at bindings/dotnet/src/Turso.Data/TursoSyncDatabaseOptions.cs:126

    public string Path { get; }
    public Uri RemoteUri { get; }
    public string? AuthToken { get; init; }
    public string ClientName { get; init; } = "turso-sync-dotnet";
    public TimeSpan? LongPollTimeout { get; init; }
    public bool BootstrapIfEmpty { get; init; } = true;
    public TursoPartialSyncOptions? PartialSync { get; init; }
    public TursoRemoteEncryptionOptions? RemoteEncryption { get; init; }
    public long? PushOperationsThreshold { get; init; }
    public long? PullBytesThreshold { get; init; }
    public bool ForceLogicalMvccPull { get; init; }
    public HttpClient? HttpClient { get; init; }
    public string? ExperimentalFeatures { get; init; }

    internal Uri GetNormalizedRemoteUri()
    {
        if (!RemoteUri.IsAbsoluteUri)
            throw new ArgumentException("The sync remote URL must be absolute.", nameof(RemoteUri));
        if (!string.IsNullOrEmpty(RemoteUri.Query) || !string.IsNullOrEmpty(RemoteUri.Fragment))
            throw new ArgumentException("The sync remote URL must not include a query string or fragment.", nameof(RemoteUri));
        if (!string.IsNullOrEmpty(RemoteUri.UserInfo))
            throw new ArgumentException("Use AuthToken instead of embedding credentials in the sync URL.", nameof(RemoteUri));
        if (string.IsNullOrEmpty(RemoteUri.Host))
            throw new ArgumentException("The sync remote URL must include a host.", nameof(RemoteUri));

        var scheme = RemoteUri.Scheme.ToLowerInvariant() switch
        {
            "turso" or "libsql" => Uri.UriSchemeHttps,
            "http" => Uri.UriSchemeHttp,
            "https" => Uri.UriSchemeHttps,
            _ => throw new ArgumentException(
                "The sync remote URL must use turso, libsql, HTTP, or HTTPS.",
                nameof(RemoteUri)),
        };
        var builder = new UriBuilder(RemoteUri)
        {

View on GitHub (pinned to c1e5928725)

Solutions

  1. Prefix the value with https:// (or turso://) before creating the Uri
  2. Use Uri.TryCreate with UriKind.Absolute and fail fast with a clear config error
  3. Validate configuration at startup so missing schemes are caught before sync is attempted

Example fix

// before: relative URI
var options = new TursoSyncDatabaseOptions(path, new Uri("my-db.turso.io"));
// after: absolute URI
var options = new TursoSyncDatabaseOptions(path, new Uri("https://my-db.turso.io"));
Defensive patterns

Strategy: validation

Validate before calling

if (!Uri.TryCreate(remoteUrl, UriKind.Absolute, out var remoteUri) || !remoteUri.IsAbsoluteUri)
    throw new ArgumentException($"Sync remote URL '{remoteUrl}' must be absolute (include the scheme, e.g. https://).", nameof(remoteUrl));

Try / catch

try
{
    var db = new TursoSyncDatabase(options);
}
catch (ArgumentException ex) when (ex.Message.Contains("sync remote URL must be absolute"))
{
    logger.LogError(ex, "Configured RemoteUri '{Remote}' is not an absolute URI; add the scheme.", remoteUrl);
    throw;
}

Prevention

When it happens

Trigger: Creating TursoSyncDatabaseOptions(path, new Uri("myserver.example.com")) — note Uri treats strings without a scheme as relative — or passing a value from config/env that lacks the https:// prefix.

Common situations: Reading the remote from an environment variable or appsettings value where the scheme was omitted; assuming Uri would infer https; string concatenation dropping the prefix.

Related errors


AI-assisted analysis of tursodatabase/turso@c1e5928725 (2026-08-31). Data as JSON: /api/errors/bf768b6c03f2445e. Report an issue: GitHub.