Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Return an empty array instead of null to indicate successful response but empty result#415

Closed
BrianCollet wants to merge 3 commits into
Azure:mainfrom
BrianCollet:fix-382
Closed

Return an empty array instead of null to indicate successful response but empty result#415
BrianCollet wants to merge 3 commits into
Azure:mainfrom
BrianCollet:fix-382

Conversation

@BrianCollet

Copy link
Copy Markdown

What does this PR do?

Returns empty array instead of omitting results field for successful responses
Updated tests to check for empty array instead of null

GitHub issue number?

Fixes #382

Checklist before merging

  • I have read the contribution guidelines on pull request process, code style, and testing.
  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • If it's a core feature, I have added thorough tests.
  • If it's a noteworthy bug fix or new feature, I have added an entry in CHANGELOG.md with a link back to the PR or issue
  • Have a team member run live tests:
    • Team Member: Inspect PR for security issues before queueing a test run
    • Team Member: Add this comment to the pr /azp run azure - mcp to start the run

@BrianCollet

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

@jongio

jongio commented Jun 19, 2025

Copy link
Copy Markdown
Member

I appreciate the time you put into this. Just a heads up that we have a PR close to being merged that will change the folder structure. I recommend waiting for that to merge, then rebase, and then update your PR. That would be easiest for you. #403

@BrianCollet

Copy link
Copy Markdown
Author

I appreciate the time you put into this. Just a heads up that we have a PR close to being merged that will change the folder structure. I recommend waiting for that to merge, then rebase, and then update your PR. That would be easiest for you. #403

Happy to contribute! I'll take another crack at it when the changes are merged. 😃

@jongio

jongio commented Jul 2, 2025

Copy link
Copy Markdown
Member

@BrianCollet - Can you now have a look?

@jongio

jongio commented Jul 11, 2025

Copy link
Copy Markdown
Member

@BrianCollet - Do you still want to contrib?

@BrianCollet

Copy link
Copy Markdown
Author

@jongio yes, my latest push on July 7th was after rebasing

@jongio

jongio commented Jul 11, 2025

Copy link
Copy Markdown
Member

Thanks, we'll get the test issue fixed.

@joshfree joshfree added the area-Core AZMCP Core functionality that all other tools build on top of label Jul 14, 2025
@joshfree joshfree added this to the 2025-08 milestone Jul 14, 2025
Comment thread .vscode/mcp.json Outdated
@jongio

jongio commented Jul 14, 2025

Copy link
Copy Markdown
Member

/azp run azure - mcp

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vcolin7

vcolin7 commented Jul 26, 2025

Copy link
Copy Markdown
Member

@BrianCollet Our big repo change just happened. You'll need to rebase your changes on top the new repo structure. I can review once it's ready :)

@jongio

jongio commented Aug 6, 2025

Copy link
Copy Markdown
Member

Sorry, @BrianCollet we are moving fast with big changes. Can you open a new PR for this?

Copilot AI review requested due to automatic review settings August 6, 2025 22:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR changes the behavior of list commands to return empty arrays instead of null when no results are found, ensuring a consistent API response structure for successful operations. This improves API predictability by guaranteeing that the results field is always present with a valid structure when the operation succeeds.

Key changes:

  • Modified all list commands to always return a populated results object containing empty collections instead of null
  • Updated corresponding unit tests to validate empty arrays rather than null values
  • Renamed test methods to reflect the new behavior

Reviewed Changes

Copilot reviewed 49 out of 50 changed files in this pull request and generated 4 comments.

File Description
Multiple *ListCommand.cs files Removed conditional logic that returned null for empty results, now always return structured response objects
Multiple *ListCommandTests.cs files Updated test expectations from null to empty arrays and improved test structure with consistent field initialization
GroupJsonContext.cs Updated JSON serialization context to use renamed result class

private sealed class SubscriptionListResult
{
[JsonPropertyName("subscriptions")]
public List<string>? Subscriptions { get; set; }

Copilot AI Aug 6, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is missing an entry in CHANGELOG.md. According to the coding guidelines, all changes should be documented in the CHANGELOG.md file in the appropriate release and section.

Copilot uses AI. Check for mistakes.
Comment on lines +57 to 58
"--subscription", _knownSubscriptionId,
"--vault", _knownVaultName,

Copilot AI Aug 6, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate arguments are being passed to the parser. Lines 56-59 contain duplicate '--vault' and '--subscription' parameters, which may cause parsing errors.

Suggested change
"--subscription", _knownSubscriptionId,
"--vault", _knownVaultName,

Copilot uses AI. Check for mistakes.
Comment on lines +85 to 86
"--subscription", _knownSubscriptionId,
"--vault", _knownVaultName,

Copilot AI Aug 6, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate arguments are being passed to the parser. Lines 83-86 contain duplicate '--vault' and '--subscription' parameters, which may cause parsing errors.

Suggested change
"--subscription", _knownSubscriptionId,
"--vault", _knownVaultName,

Copilot uses AI. Check for mistakes.
Comment on lines +116 to 117
"--subscription", _knownSubscriptionId,
"--vault", _knownVaultName,

Copilot AI Aug 6, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate arguments are being passed to the parser. Lines 114-117 contain duplicate '--vault' and '--subscription' parameters, which may cause parsing errors.

Suggested change
"--subscription", _knownSubscriptionId,
"--vault", _knownVaultName,

Copilot uses AI. Check for mistakes.
@jongio

jongio commented Aug 6, 2025

Copy link
Copy Markdown
Member

@anuchandy - Can you review this?

@jongio jongio requested a review from anuchandy August 6, 2025 23:38

@anuchandy anuchandy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @BrianCollet, Thanks a lot for the contribution! Is it possible to scope the PR changes to only about returning [] array (instead of null) and test for that specific case?

There appear to be several formatting changes across tests, as well as new variables, logic and deserialization of results. Can those be reverted so that only the tests previously checking for null result are updated to check for an empty array? To keep things straightforward, we can simply compare against "[]" rather than deserializing.

If reverting is too much work due to the number of files, as Jon suggested, you can considering opening a new PR based of latest main focused only on the empty array.

@jongio jongio assigned anuchandy and unassigned jongio Aug 7, 2025
@BrianCollet

Copy link
Copy Markdown
Author

@anuchandy yeah I'll close this PR and open a new one focusing only on the empty array. Thanks!

@BrianCollet BrianCollet closed this Aug 7, 2025
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Azure MCP Server (OLD) Aug 7, 2025
@anuchandy

Copy link
Copy Markdown
Member

@anuchandy yeah I'll close this PR and open a new one focusing only on the empty array. Thanks!

thanks @BrianCollet looking forward to it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Core AZMCP Core functionality that all other tools build on top of

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Small improvement: use an empty array to indicate successful but empty result

6 participants