Resource and Canonical Properties use of null
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Rust
- Sterne
- 526
- Forks
- 76
- Ø Merge
- 3 T. 16 Std.
- Gemergte PRs (30 T.)
- 24
Beschreibung
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Summary
There are built-in resources and canonical properties (_inDesiredState) that use null in addition to actual type of the property. Null should NOT be a valid type unless the property actually accepts null as a valid use case. By allowing null it can confuse users when we have auto-complete in BICEP and weakens the strongly validated schema.
JSON schema null and undefined properties are different.
https://json-schema.org/understanding-json-schema/reference/null
Excerpt:
It's important to remember that in JSON, null isn't equivalent to something being absent. See Required Properties for an example.
The mechanism to indicate a property is required or optional is by the use of the required property.
I understand that we're using nullable types so we can return only the properties that are actually defined instead of empty strings or false bools but it is not best practice.
Resources with Nullable Properties:
-
Microsoft.DSC.Debug/Echo
showSecrets:type: ["boolean", "null"] -
Microsoft.DSC.Transitional/PowerShellScript
getScript:type: ["string", "null"]
setScript:type: ["string", "null"]
testScript:type: ["string", "null"]
input:type: ["string", "boolean", "integer", "object", "array", "null"]
output:type: ["array", "null"]
_inDesiredState:type: ["boolean", "null"] -
Microsoft.DSC.Transitional/WindowsPowerShellScript
getScript:type: ["string", "null"]
setScript:type: ["string", "null"]
testScript:type: ["string", "null"]
input:type: ["string", "boolean", "integer", "object", "array", "null"]
output:type: ["array", "null"]
_inDesiredState:type: ["boolean", "null"] -
Microsoft.OpenSSH.SSHD/Windows
shell:type: ["string", "null"]
cmdOption:type: ["string", "null"]
escapeArguments:type: ["boolean", "null"] -
Microsoft.Windows/RebootPending
reasons:type: ["array", "null"]
The entire object itself:type: ["object", "null"] -
Microsoft.Windows/Registry
_metadata:anyOf: [{"$ref": "#/$defs/Metadata"}, {"type": "null"}]
valueName:type: ["string", "null"]
valueData:anyOf: [{"$ref": "#/$defs/RegistryValueData"}, {"type": "null"}]
_exist:type: ["boolean", "null"]
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Überprüfung der JSON-Schemas für die aufgeführten DSC-Ressourcen und der kanonischen Eigenschaft _inDesiredState, wobei die Ressourcen- und Eigenschaftenliste des Issues den Umfang vorgibt. Prüfe, welche Eigenschaften tatsächlich null akzeptieren und welche lediglich optional sind, und validiere anschließend die resultierenden Schemas anhand der dokumentierten JSON-Schema-Semantik und der Erwartungen der Bicep-Autovervollständigung. Erledigt bedeutet, ungerechtfertigte Nulltypen zu entfernen und gleichzeitig legitime nullable Werte beizubehalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- json
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100