Skip to content

Add FileNameStar to MultipartFileContent in WebCmdlets #19467

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
Jun 12, 2023

Conversation

CarloToso
Copy link
Contributor

@CarloToso CarloToso commented Apr 7, 2023

PR Summary

  1. Add FileNameStar to MultipartFileContent
  1. Now .Net add quotes as needed so remove the code.

PR Context

Removed linked issue as this PR doesn't fix that issue

PR Checklist

@CarloToso CarloToso requested a review from PaulHigin as a code owner April 7, 2023 18:38
@ghost ghost assigned TravisEz13 Apr 7, 2023
@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Apr 8, 2023
@iSazonov iSazonov changed the title WebCmdlets add FileNameStar to MultipartFileContent Add FileNameStar to MultipartFileContent in WebCmdlets Apr 8, 2023
@daxian-dbw
Copy link
Member

@CarloToso Can you please update the PR description with more context information about why adding FileNameStar? Also, can you please confirm whether it fixes #19456?

@CarloToso
Copy link
Contributor Author

@daxian-dbw Updated the PR description, I can't confirm it fixes the issue because it depends on the endpoint that recieves the Multipart/Form-Data

@daxian-dbw
Copy link
Member

daxian-dbw commented Apr 11, 2023

Thanks @CarloToso. Let's wait for the user to verify the fix.
#19456 (comment)

@ghost ghost added the Review - Needed The PR is being reviewed label Apr 19, 2023
@ghost
Copy link

ghost commented Apr 19, 2023

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@daxian-dbw daxian-dbw added WG-Cmdlets general cmdlet issues Needs-Triage The issue is new and needs to be triaged by a work group. labels May 1, 2023
@TravisEz13
Copy link
Member

This did not fix the customer's issue. Do we still want to proceed with this fix?

@ghost ghost removed the Review - Needed The PR is being reviewed label May 1, 2023
@TravisEz13 TravisEz13 added Needs-Triage The issue is new and needs to be triaged by a work group. Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Needs-Triage The issue is new and needs to be triaged by a work group. labels May 1, 2023
@CarloToso
Copy link
Contributor Author

@TravisEz13 I think we should merge this PR anyway

@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label May 2, 2023
@iSazonov
Copy link
Collaborator

iSazonov commented May 3, 2023

This add useful standard behavior.

@TravisEz13
Copy link
Member

I pinged WG-Cmdlets to triage.

@SteveL-MSFT
Copy link
Member

Looking at the HTTP specs, it seems that this is useful even though it doesn't solve the original problem.

@JamesWTruher
Copy link
Collaborator

if we're adding new or altering current behavior, there should be some validation.

Copy link
Collaborator

@JamesWTruher JamesWTruher left a comment

Choose a reason for hiding this comment

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

This really should have some validation of the behavior.

// .NET does not enclose field names in quotes, however, modern browsers and curl do.
result.Headers.ContentDisposition.FileName = "\"" + file.Name + "\"";
result.Headers.ContentDisposition.FileName = file.Name;
result.Headers.ContentDisposition.FileNameStar = file.Name;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should have tests for this new behavior.

Copy link
Contributor Author

@CarloToso CarloToso May 8, 2023

Choose a reason for hiding this comment

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

Done
I'll fix it tomorrow
Done

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label May 8, 2023
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label May 8, 2023
@pull-request-quantifier-deprecated

This PR has 38 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Small
Size       : +35 -3
Percentile : 15.2%

Total files changed: 2

Change summary by file extension:
.cs : +4 -3
.ps1 : +31 -0

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@CarloToso CarloToso requested a review from JamesWTruher May 9, 2023 10:24
@ghost ghost added the Review - Needed The PR is being reviewed label May 16, 2023
@ghost
Copy link

ghost commented May 16, 2023

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@StevenBucher98 StevenBucher98 added the PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed label Jun 5, 2023
@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Jun 7, 2023

@PowerShell/wg-powershell-cmdlets discussed this briefly and agree on supporting FileNameStar. The linked issue is not resolved by this PR, so we removed the link to the issue.

@ghost ghost removed the Review - Needed The PR is being reviewed label Jun 7, 2023
@SteveL-MSFT SteveL-MSFT removed the Needs-Triage The issue is new and needs to be triaged by a work group. label Jun 7, 2023
Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

Tests look good to me

Copy link
Collaborator

@JamesWTruher JamesWTruher left a comment

Choose a reason for hiding this comment

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

thanks for adding the validation!

@daxian-dbw daxian-dbw merged commit 1822ad7 into PowerShell:master Jun 12, 2023
@daxian-dbw daxian-dbw removed the PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed label Jun 12, 2023
@ghost
Copy link

ghost commented Jun 29, 2023

🎉v7.4.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

@marekvinkler
Copy link

It is possible this change is breaking Invoke-RestMethod calls with multipart/form-data, i.e.

$form = @{
  "file"      = Get-Item -Path $File
}
Invoke-RestMethod -Uri $Url -Method POST -Headers $headers -Form $form

results in an malformed request.


// .NET does not enclose field names in quotes, however, modern browsers and curl do.
contentDisposition.Name = "\"" + LanguagePrimitives.ConvertTo<string>(fieldName) + "\"";
contentDisposition.Name = LanguagePrimitives.ConvertTo<string>(fieldName);
Copy link

@rkeithhill-keysight rkeithhill-keysight Jun 27, 2024

Choose a reason for hiding this comment

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

This broke IWR for us when we upgraded to 7.4. We use IWR in a publish script to upload a zip to an internal PERL / CGI-based website. AFAICT the PERL CGI module requires field name values to be quoted. See #23843

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Extra Small WG-Cmdlets general cmdlet issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants