PowerShell / PowerShell/DSC

Resource and Canonical Properties use of null

Aperta
#1,237 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Issue-Bug Need-Review
Lingua principale
Rust
Stelle
523
Fork
75
Merge medio
3g 16h
PR unite (30g)
24

Descrizione

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:

  1. Microsoft.DSC.Debug/Echo
    showSecrets: type: ["boolean", "null"]

  2. 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"]

  3. 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"]

  4. Microsoft.OpenSSH.SSHD/Windows
    shell: type: ["string", "null"]
    cmdOption: type: ["string", "null"]
    escapeArguments: type: ["boolean", "null"]

  5. Microsoft.Windows/RebootPending
    reasons: type: ["array", "null"]
    The entire object itself: type: ["object", "null"]

  6. 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"]

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando gli schemi JSON per le risorse DSC elencate e la proprietà canonica _inDesiredState, usando come ambito l’elenco di risorse e proprietà dell’issue. Verifica quali proprietà accettano effettivamente null rispetto a quelle che sono semplicemente facoltative, quindi valida gli schemi risultanti rispetto alla semantica documentata di JSON Schema e alle aspettative del completamento automatico di Bicep. Il lavoro è completato quando vengono rimossi i tipi null ingiustificati, preservando al contempo i valori nullable legittimi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
json
Ambito
tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.