Skip to content

UntypedString.Value inaccessible in IntelliSense when using CustomSecurityAttributes #7160

@rmoulliettexana

Description

@rmoulliettexana

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Windows executable

Client library/SDK language

Csharp

Describe the bug

When using Microsoft.Kiota.Abstractions.Serialization.UntypedString inside User.CustomSecurityAttributes in the Microsoft Graph SDK (C#):

The .Value property exists at runtime but is internal.

IntelliSense does not show .Value.

Attempting to access .Value directly in code causes a compiler error.

This is confusing because the value exists at runtime but cannot be accessed safely or discoverably via normal developer tools.

Expected behavior

Developers should be able to access the runtime value of UntypedString without using dynamic.

IntelliSense should show .Value if it exists, or the SDK should provide a public method/property for safe access.

How to reproduce

Query users via GraphServiceClient including customSecurityAttributes:

var userPage = await graphClient.Users.GetAsync(config =>
{
    config.QueryParameters.Select = new[]
    {
        "userPrincipalName",
        "displayName",
        "mail",
        "customSecurityAttributes"
    };
});

Iterate through the users and try to read a custom attribute:

var pageIterator = PageIterator<User, UserCollectionResponse>.CreatePageIterator(
    graphClient,
    userPage,
    (user) =>
    {
        string customAttributeValue = "";
        if (user.CustomSecurityAttributes?.AdditionalData != null &&
            user.CustomSecurityAttributes.AdditionalData.TryGetValue("Namespace", out var raw))
        {
            if (raw is Microsoft.Kiota.Abstractions.Serialization.UntypedObject uo)
            {
                var dict = uo.GetValue(); // Dictionary<string, object>
                if (dict.TryGetValue("AttributeName", out var node))
                {
                    // Fails at compile-time:
                    // customAttributeValue = node.Value;

                    // Works at runtime:
                    customAttributeValue = ((dynamic)node).GetValue()?.ToString() ?? "";
                }
            }
        }
        return true;
    });

await pageIterator.IterateAsync();

Observe that node.Value is inaccessible via IntelliSense and causes a compile error.

Open API description file

No response

Kiota Version

Tested with Microsoft.Kiota.Abstractions version 1.17.1

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

Use dynamic + GetValue() to retrieve the actual value:

var value = ((dynamic)node).GetValue()?.ToString() ?? "";

Configuration

No response

Debug output

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    CsharpPull requests that update .net codestatus:waiting-for-triageAn issue that is yet to be reviewed or assignedtype:bugA broken experience

    Type

    No type

    Projects

    Status

    Needs Triage 🔍

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions