This is an edge case, but a real one that happened, so perhaps it's worth improving.
The Encryption field in plist output from diskutil appears to be optional actually, at least in the presence of a faulty disk which the command reports with a successful exit status.
I happen to have a faulty external disk attached, for which diskutil apfs list reports an error string in the Encrypted field where the relevant bit looks like this in the human-readable output (notice the final line):
+-- Container disk5 70967390-346F-4062-B600-D559E11B9625
====================================================
APFS Container Reference: disk5
Size (Capacity Ceiling): 999994101760 B (1000.0 GB)
Capacity In Use By Volumes: 613823676416 B (613.8 GB) (61.4% used)
Capacity Not Allocated: 386170425344 B (386.2 GB) (38.6% free)
|
+-< Physical Store disk4s2 435B27E3-03BD-4B4B-942B-DB6C74E514FB
| -----------------------------------------------------------
| APFS Physical Store Disk: disk4s2
| Size: 999994101760 B (1000.0 GB)
|
+-> Volume disk5s1 E04BD327-E0C1-4B31-BE82-97F4D68DD072
| ---------------------------------------------------
| APFS Volume Disk (Role): disk5s1 (No specific role)
| Name: Heen (Case-insensitive)
| Mount Point: Not Mounted
| Capacity Consumed: 104920772608 B (104.9 GB)
| Sealed: No
| FileVault: No
|
+-> Volume disk5s3 51A18CB8-3F37-456F-8F00-D11D5B1268AB
---------------------------------------------------
APFS Volume Disk (Role): disk5s3 (Backup)
Name: Time Machine (Case-sensitive)
Mount Point: Not Mounted
Capacity Consumed: 508695658496 B (508.7 GB)
Encrypted: ERROR -69461
In plist format, I guess given that it isn't certain of a decisive boolean value, the Encryption field just gets omitted altogether:
Note that some other volume fields like <FileVault> and <Locked> are also absent, so may want to consider whether all of these can be handled gracefully. (Perhaps it's even normal for fields to vary for Time Machine volumes—the backup role—even if not faulty?)
Error
Metadata
This is an edge case, but a real one that happened, so perhaps it's worth improving.
The
Encryption
field in plist output from diskutil appears to be optional actually, at least in the presence of a faulty disk which the command reports with a successful exit status.I happen to have a faulty external disk attached, for which
diskutil apfs list
reports an error string in theEncrypted
field where the relevant bit looks like this in the human-readable output (notice the final line):In plist format, I guess given that it isn't certain of a decisive boolean value, the
Encryption
field just gets omitted altogether:Long-ish plist snippet
```xmlNote that some other volume fields like
<FileVault>
and<Locked>
are also absent, so may want to consider whether all of these can be handled gracefully. (Perhaps it's even normal for fields to vary for Time Machine volumes—the backup role—even if not faulty?)