Resource and Canonical Properties use of null
まだ誰も着手していません。
- 主要言語
- Rust
- スター
- 526
- フォーク
- 76
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 24
説明
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"]
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、一覧に記載された DSC リソースの JSON スキーマと、正規の _inDesiredState プロパティを確認します。対象範囲は issue のリソースおよびプロパティ一覧とします。各プロパティが実際に null を受け入れるのか、それとも単に省略可能なのかを確認し、そのうえで、結果のスキーマを文書化された JSON Schema のセマンティクスおよび Bicep のオートコンプリートの期待値に照らして検証します。不当な null 型を削除しつつ、正当な nullable 値を維持できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- json
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100