Test-Json returns wrong error when SchemaFile is not found
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 74/100
Piste de recherche
Commencez par TestJsonCommand.BeginProcessing et l’appel à JsonSchema.FromFile, puis exécutez la reproduction Test-Json fournie avec le fichier fooSchema.json manquant. C’est terminé lorsque le schéma manquant produit l’erreur attendue « Cannot find JSON schema file » sur le chemin indiqué, au lieu du libellé actuel d’ouverture de fichier.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Use a valid json file test.json as shown in below example. Test its schema by passing an invalid schema file json.
> cat test.json
{
"str": "somestring",
"int": 2026
}
>Test-Json -Path .\test.json -SchemaFile .\fooSchema.json
Expected behavior
Test-Json: Cannot find JSON schema file: C:\Windows\Temp\fooSchema.json
Actual behavior
> Test-Json: Can not open JSON schema file: C:\Windows\Temp\fooSchema.json
Error details
Exception :
Type : System.Exception
TargetSite :
Name : ThrowTerminatingError
DeclaringType : [System.Management.Automation.MshCommandRuntime]
MemberType : Method
Module : System.Management.Automation.dll
Message : Can not open JSON schema file: C:\Windows\Temp\fooSchema.json
InnerException :
Type : System.IO.FileNotFoundException
Message : Could not find file 'C:\Windows\Temp\fooSchema.json'.
FileName : C:\Windows\Temp\fooSchema.json
TargetSite :
Name : CreateFile
DeclaringType : [Microsoft.Win32.SafeHandles.SafeFileHandle]
MemberType : Method
Module : System.Private.CoreLib.dll
Source : System.Private.CoreLib
HResult : -2147024894
StackTrace :
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Int32 bufferSize)
at System.IO.File.ReadAllText(String path, Encoding encoding)
at Json.Schema.JsonSchema.FromFile(String fileName)
at Microsoft.PowerShell.Commands.TestJsonCommand.BeginProcessing()
Source : System.Management.Automation
HResult : -2146233088
StackTrace :
at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
TargetObject : C:\Windows\Temp\fooSchema.json
CategoryInfo : OpenError: (C:\Windows\Temp\fooSchema.json:String) [Test-Json], Exception
FullyQualifiedErrorId : JsonSchemaFileOpenFailure,Microsoft.PowerShell.Commands.TestJsonCommand
InvocationInfo :
MyCommand : Test-Json
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 1
Line : Test-Json -Path .\test.json -SchemaFile .\fooSchema.json
Statement : Test-Json -Path .\test.json -SchemaFile .\fooSchema.json
PositionMessage : At line:1 char:1
+ Test-Json -Path .\test.json -SchemaFile .\fooSchema.json
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Test-Json
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
#Windows
Name Value
---- -----
PSVersion 7.6.5
PSEdition Core
GitCommitId 7.6.5
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
#Linux
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Ubuntu 20.04.6 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
- Langage dominant
- C#
- Étoiles
- 55.5k
- Forks
- 8.5k
- Merge moyen
- 1 j 14 h
- PR mergées (30 j)
- 107
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de PowerShell/PowerShell
-
Issue-Enhancement Needs-Triage WG-Cmdlets
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
PowerShell/PowerShell#28061 · 1 commentaire · 2 réactions ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
PowerShell/PowerShell#28037 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
PowerShell/PowerShell#27720 ·
-
Issue-Bug Up-for-Grabs WG-Cmdlets WG-Reviewed
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
PowerShell/PowerShell#27670 · 3 commentaires ·
-
Issue-Bug Up-for-Grabs WG-Reviewed
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
PowerShell/PowerShell#27656 · 2 commentaires ·
Toutes les issues de PowerShell/PowerShell
Issues similaires
-
core dependencies
Difficulté 1/5 Moins d'une heure Accessibilité débutants 80/100
-
bug frontend good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
NavigationViewItemAutomationPeer implements IInvokeProvider but never advertises the Invoke pattern Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
unoplatform/uno#24629 ·
-
agentic-workflows Needs: Triage :mag: State: In-PR
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
Down / Waiting for removal
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100