GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — Fix Single Value JSON null in Invoke-RestMethod by markekraus · Pull Request #5338 · PowerShell/PowerShell Conversation
Contributor
closes #5320 When an API returns just Invoke-RestMethod is already properly managing This PR fixes the logic in This is a breaking change in the sense that users who are using
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Mark Kraus (markekraus)
requested review from
James Truher (JamesWTruher),
Paul Higinbotham (PaulHigin) and
Dan Travison (dantraMSFT)
as code owners
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why the fix so high level? It seems Also please review JsonSerializerSettings.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
|
Ilya (@iSazonov) I switched to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
After I see the change I'm even more confident that we should make this check in ConvertFromJson - we should remove if ((Regex.Match(input, @"^\s*\[")).Success) and replace JArray.Parse(input); with JToken.Parse(json);. So we'll be closer to JavaScriptSerializer, and we can make it easier to move on one in the future. Also we exclude the same catch on level above.
I review a history of the code and discover that I see ways to clean up and refactor the code. So I agree to merge the PR as is and ready to refactor in days.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Just note that just like the change here, making that change ConvertFromJson() will be a breaking change since empty strings and whitespace-only strings will produce errors where as before they returned $null. I think that's appropriate, but the world at large may not. But you are right, we don't have much time. Will you handle the ConvertFromJson() refactor?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'd refactor the code in any case because it provokes troubles.
As for a breaking change I have the thoughts - should we fix the Issue now or leave the behavior as in Windows PowerShell? Will MSFT fix the Issue in Windows PowerShell too and when? Will MSFT fix the Issue in .Net JavaScriptSerializer and when? Should we request the fix in Newton.Json as we did for JArray?
I think to get sync fixes is better then a breaking change in only PowerShell Core.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ilya (@iSazonov) Good questions, but we should track that in a separate issue.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
/cc Steve Lee (@SteveL-MSFT) this one should probably be merged before RC unless we plan to break this in 6.1. committee approved breaking change here #5320 (comment) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, add test(s) for the error case where the JSON cannot be parsed?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Travis Plunk (@TravisEz13) if by "error" you mean empty strings or whitspace-only? I can add the tests, but they will just be ensuring a a String.Empty returns a String.Empty and that a whitespace string returns a whitespace string. When that error condition hits, the cmdlet just goes to the next serialization type (xml) and then when that fails it just returns the string.
It also looks like I would need to either add a WebListener controller to another switch option to HttpListener. Currently none of the available tests can return whitespace only responses. All of them truncate to 0 bytes when the body payload is all whitespace.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have the test to ensure good coverage, but I think this is adequate.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I've created #5414 to add coverage for that. I have a backlog of test and cleanup activities to do, I'll start on those after RC is underway.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@PowerShell/powershell-maintainers Steve Lee (@SteveL-MSFT) Joey Aiello (@joeyaiello) I recommend we take this for RC. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark Kraus (@markekraus) Travis Plunk (@TravisEz13) yes, please take for RC |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Are we ready to merge? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to use `n for newline whitespace than rely on the line endings of the file
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
fixed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) I think this is ready to merge |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Reopen to restart CI. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) *sigh. It looks like both Travis CI tests passed, but it has not updated the PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I can not manually merge 😕 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark Kraus (@markekraus) can you rebase and pick up #5249? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1c58efc to
4a5d6f7
Compare
|
rebased. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mark Kraus (@markekraus) there is a merge conflict now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
4a5d6f7 to
d968c99
Compare
|
rebased. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
restarted appveyor due to github rate limit failure |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* [Feature] Fix Single Value JSON null in Invoke-WebRequest * [Feature] Switch from Regex to JToken.Parse() * [Feature] Address PR Feedback: use `n
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Invoke-RestMethod doesn't return useful info when no data is returned.
There was an error while loading. Please reload this page.