Skip to content

Conversation

@gregsdennis
Copy link
Contributor

@daxian-dbw, this is the same as #19610, but I want to use this for testing so I don't gunk up the commit history over there. Please approve any builds if you need to. Otherwise, feel free to ignore.

!!! NOT FOR MERGING !!!

@gregsdennis
Copy link
Contributor Author

Looks like this is the problem, which is what I suspected:

Microsoft.PowerShell.Commands.JsonSchemaReferenceResolutionException: Exception of type 'Microsoft.PowerShell.Commands.JsonSchemaReferenceResolutionException' was thrown.
 ---> System.IO.DirectoryNotFoundException: Could not find a part of the path '/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Utility/assets/valid_schema_definitions.json'.

I don't understand this because the file is definitely there.

Adding more logs...

@gregsdennis
Copy link
Contributor Author

More detail:

Fetching: /vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Utility/assets/valid_schema_definitions.json
Reading file: /vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Utility/assets/valid_schema_definitions.json
Json.Schema.JsonSchemaException: Cannot resolve base schema from `file://home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Utility/assets/valid_schema_definitions.json#/definitions/name`

I'm unsure why this isn't able to find the file. I'm open to ideas from someone who know linux better.

@gregsdennis gregsdennis mentioned this pull request May 5, 2023
22 tasks
@gregsdennis
Copy link
Contributor Author

Okay. It looks like it's a difference in how filename URIs are handled.

var windowsFilePath = "C:\\Folder\\target.json";
var unixFilePath = "/Folder/target.json";

var windowsFileUri = new Uri($"file:///{windowsFilePath}");
var unixFileUri = new Uri($"file:///{unixFilePath}");

Console.WriteLine(windowsFileUri);
Console.WriteLine(windowsFileUri.AbsoluteUri);
Console.WriteLine(windowsFileUri.AbsolutePath);
Console.WriteLine();
Console.WriteLine(unixFileUri);
Console.WriteLine(unixFileUri.AbsoluteUri);
Console.WriteLine(unixFileUri.AbsolutePath);
Console.WriteLine(unixFileUri.Host);
file:///C:/Folder/target.json
file:///C:/Folder/target.json
C:/Folder/target.json

file://folder/target.json
file://folder/target.json
/target.json
folder

That last line is missing the folder. It's interpreted as the host and not included in the path.

Also interesting is the lower-casing. Since *nix operating systems have case-sensitive file systems, I wonder if that's going to cause a problem.

@adityapatwardhan @daxian-dbw I would love to get your thoughts on this.

@gregsdennis
Copy link
Contributor Author

Looks like I might be able to just use .LocalPath.

Windows: C:\Folder\target.json
*nix: \\folder\target.json

@gregsdennis
Copy link
Contributor Author

Getting closer. Not sure why it's changing to backslashes.

Fetching: file://home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Utility/assets/valid_schema_definitions.json
Reading file: \\home\vsts\work\1\s\test\powershell\Modules\Microsoft.PowerShell.Utility\assets\valid_schema_definitions.json

@iSazonov
Copy link
Collaborator

iSazonov commented May 5, 2023

I wonder to see #/definitions/name tail:

JsonSchemaException: Cannot resolve base schema from `file://home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Utility/assets/valid_schema_definitions.json#/definitions/name

@gregsdennis
Copy link
Contributor Author

No, the fragment is removed before attempting to fetch the file. Only the base URI is used in the fetching code. The fragment only is resolved after the file content is retrieved.

@iSazonov
Copy link
Collaborator

iSazonov commented May 5, 2023

Interesting file:///var/ vs file://var/:
uri

@gregsdennis
Copy link
Contributor Author

gregsdennis commented May 5, 2023

Yep... Looks like the problem is in how I build the base URI from a *nix file path. I'll push out a release and update here first. If it works, then I'll apply changes to the other PR and close this. Then we can all move on.

Ref: json-everything/json-everything#447

@pull-request-quantifier-deprecated

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


Quantification details

Label      : Medium
Size       : +74 -50
Percentile : 44.8%

Total files changed: 4

Change summary by file extension:
.csproj : +1 -1
.cs : +69 -48
.resx : +4 -1

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.

@gregsdennis
Copy link
Contributor Author

Not sure why more tests are failing, but the URI issue is resolved. Probably my other error handling changes.

I'm going to just update the package version on the other PR and see what happens there. The pester tests work locally on that branch with the new version. Closing this for now.

@gregsdennis gregsdennis closed this May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants