Awesome Reviewers

When a value is optional in Bicep, use nullable parameter types and null-safe property emission instead of sentinel values (like empty strings) or json('null').

Apply these rules: 1) Make parameters nullable when they can be omitted

param addressPrefix string?

(or param addressPrefix string = null if your style prefers explicit defaults)

2) For optional object fields, set the field to null (or omit the field)

3) Use native null, not json('null')

zones: (length(availabilityZones) == 0) ? null : availabilityZones

4) Guard optional properties with contains() to avoid “property doesn’t exist” errors

properties: {
  nsgId: contains(subnet, 'nsgId') ? (empty(subnet.nsgId) ? null : subnet.nsgId) : null
}

Net effect: templates stay null-safe, avoid invalid payload fields, and reduce runtime/validation errors caused by missing properties or incorrect null representations.