Skip to content

[Synapse]fix remove artifact throw exception ArgumentNullException #28123

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

Merged
merged 6 commits into from
Jul 3, 2025

Conversation

kevinzz6
Copy link
Member

@kevinzz6 kevinzz6 commented Jul 3, 2025

Description

fix when remove artifact, responseContent?.ToString() throw exception ArgumentNullException

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 05:43
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Contributor

@Copilot Copilot AI left a comment

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 adds a guard to avoid calling ToString() on an empty response content, preventing an ArgumentNullException when removing an artifact.

  • Adds a check on ContentStream.Length == 0 to return early if the response is empty
  • Preserves original logic to throw an exception for non-empty content
  • Updates comments to explain the new guard
Comments suppressed due to low confidence (1)

src/Synapse/Synapse/Common/Utils.cs:244

  • Consider adding a unit test to cover the new empty-content branch where ContentStream.Length == 0.
            if (result.ContentStream.Length == 0)


//Fix when responseContent.length is 0 responseContent?.ToString() will throw exception ArgumentNullException
if (result.ContentStream.Length == 0)
Copy link
Member

Choose a reason for hiding this comment

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

better to check result.ContentStream is null first? as it can be a Stream?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@YanaXu
Copy link
Contributor

YanaXu commented Jul 3, 2025

/azp run

Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@YanaXu
Copy link
Contributor

YanaXu commented Jul 3, 2025

/azp run

Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@YanaXu
Copy link
Contributor

YanaXu commented Jul 3, 2025

/azp run

Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

@YanaXu YanaXu merged commit 155b6ef into Azure:main Jul 3, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants