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

.Net: Fix mapping of the KernelParameterMetadata.IsRequired property #11309

Conversation

SergeyMenshykh
Copy link
Member

@SergeyMenshykh SergeyMenshykh commented Apr 1, 2025

Motivation, Context and Description

This PR fixes the issue caused by accessing the required property value as if it were a boolean property, instead of accessing it as an array of strings. Additionally, it reads the required property from the object root instead of reading it from each individual property of the object because the required property is defined at the root level to specify which properties are mandatory for the entire object.

So, when iterating over the object root level properties, the code now uses the "required": ["options"] property declared at the root level instead of the "required": ["outputPath"] declared at the options property level.

{
    "type": "object",
    "properties": {
        "options": {
            "type": "object",
            "description": "Code generation options",
            "properties": {
                "outputPath": {
                    "type": "string",
                    "description": "Directory path where generated tests will be saved (use absolute path)"
                },
                "testNamePrefix": {
                    "type": "string",
                    "description": "Prefix to use for generated test names (default: \u0027GeneratedTest\u0027)"
                },
                "includeComments": {
                    "type": "boolean",
                    "description": "Whether to include descriptive comments in generated tests"
                }
            },
            "required": [
                "outputPath"
            ]
        }
    },
    "required": [
        "options"
    ]
}

JsonSpec: https://json-schema.org/understanding-json-schema/reference/object#required
Fixes: #11292
Contributes to: #11212

@SergeyMenshykh SergeyMenshykh requested a review from a team as a code owner April 1, 2025 14:13
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel kernel.core labels Apr 1, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Apr 1, 2025
Merged via the queue into microsoft:main with commit a86b2b9 Apr 1, 2025
20 checks passed
@SergeyMenshykh SergeyMenshykh deleted the fix-parameter-isrequired-detection branch April 1, 2025 20:54
eavanvalkenburg pushed a commit to eavanvalkenburg/semantic-kernel that referenced this pull request Apr 2, 2025
…icrosoft#11309)

### Motivation, Context and Description

This PR fixes the issue caused by accessing the `required` property
value as if it were a boolean property, instead of accessing it as an
array of strings. Additionally, it reads the `required` property from
the object root instead of reading it from each individual property of
the object because the `required` property is defined at the root level
to specify which properties are mandatory for the entire object.

So, when iterating over the object root level properties, the code now
uses the `"required": ["options"]` property declared at the root level
instead of the `"required": ["outputPath"]` declared at the `options`
property level.
```json
{
    "type": "object",
    "properties": {
        "options": {
            "type": "object",
            "description": "Code generation options",
            "properties": {
                "outputPath": {
                    "type": "string",
                    "description": "Directory path where generated tests will be saved (use absolute path)"
                },
                "testNamePrefix": {
                    "type": "string",
                    "description": "Prefix to use for generated test names (default: \u0027GeneratedTest\u0027)"
                },
                "includeComments": {
                    "type": "boolean",
                    "description": "Whether to include descriptive comments in generated tests"
                }
            },
            "required": [
                "outputPath"
            ]
        }
    },
    "required": [
        "options"
    ]
}
```
JsonSpec:
https://json-schema.org/understanding-json-schema/reference/object#required
Fixes: microsoft#11292
Contributes to:
microsoft#11212
glorious-beard pushed a commit to glorious-beard/semantic-kernel that referenced this pull request Apr 6, 2025
…icrosoft#11309)

### Motivation, Context and Description

This PR fixes the issue caused by accessing the `required` property
value as if it were a boolean property, instead of accessing it as an
array of strings. Additionally, it reads the `required` property from
the object root instead of reading it from each individual property of
the object because the `required` property is defined at the root level
to specify which properties are mandatory for the entire object.

So, when iterating over the object root level properties, the code now
uses the `"required": ["options"]` property declared at the root level
instead of the `"required": ["outputPath"]` declared at the `options`
property level.
```json
{
    "type": "object",
    "properties": {
        "options": {
            "type": "object",
            "description": "Code generation options",
            "properties": {
                "outputPath": {
                    "type": "string",
                    "description": "Directory path where generated tests will be saved (use absolute path)"
                },
                "testNamePrefix": {
                    "type": "string",
                    "description": "Prefix to use for generated test names (default: \u0027GeneratedTest\u0027)"
                },
                "includeComments": {
                    "type": "boolean",
                    "description": "Whether to include descriptive comments in generated tests"
                }
            },
            "required": [
                "outputPath"
            ]
        }
    },
    "required": [
        "options"
    ]
}
```
JsonSpec:
https://json-schema.org/understanding-json-schema/reference/object#required
Fixes: microsoft#11292
Contributes to:
microsoft#11212
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel.core kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
Status: Sprint: Done
Development

Successfully merging this pull request may close these issues.

.Net: Bug: InvalidOperationException while using working with Playwright MCP Tools
4 participants