Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: (dotnet sdk) NullReferenceException on CreateAttribute if Required is true and Default is null #922

Open
2 tasks done
dydimos opened this issue Jul 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dydimos
Copy link

dydimos commented Jul 28, 2024

👟 Reproduction steps

When I call databases.CreateStringAttribute and Required is set to true, and Default is set to null.

👍 Expected behavior

It should create the attribute and return the result.

👎 Actual Behavior

It actually creates the attribute but then throws a NullReferenceException.

The Exception is thrown in this method:

    public static AttributeString From(Dictionary<string, object> map) => new AttributeString(
        key: map["key"].ToString(),
        type: map["type"].ToString(),
        status: map["status"].ToString(),
        error: map["error"].ToString(),
        required: (bool)map["required"],
        array: (bool?)map["array"],
        size: Convert.ToInt64(map["size"]),
        xdefault: map.TryGetValue("default", out var xdefault) ? xdefault.ToString() : null
    );

After changing the line
xdefault: map.TryGetValue("default", out var xdefault) ? xdefault.ToString() : null
to
xdefault: map.TryGetValue("default", out var xdefault) && xdefault != null ? xdefault.ToString() : null

it works.

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

Windows

🧱 Your Environment

I use the dotnet sdk nuget package 0.8.3.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@dydimos dydimos added the bug Something isn't working label Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant