ninxsoft / mist-cli

A Mac command-line tool that automatically downloads macOS Firmwares / Installers.
MIT License
611 stars 29 forks source link

Export JSON exception - Invalid type in JSON write (__SwiftValue) #78

Closed n8felton closed 2 years ago

n8felton commented 2 years ago

Using a version of Mist pulled from main @ c358f8f

Command

sudo mist download installer --output-directory '/Users/Shared/Mist/%VERSION%/%BUILD%' --cache-downloads --export '.metadata.json' --force --image-name 'Install_macOS_%VERSION%-%BUILD%.dmg' 12 image

Output

┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
  ├─ User is 'root'...
  ├─ Download search string will be '12'...
  ├─ Include betas in search results will be 'false'...
  ├─ Cache downloads will be 'true'...
  ├─ Output directory will be '/Users/Shared/Mist/%VERSION%/%BUILD%'...
  ├─ Temporary directory will be '/private/tmp/com.ninxsoft.mist'...
  ├─ Force flag set, existing files will be overwritten...
  ├─ Export path will be '.metadata.json'...
  ├─ Export path file extension is valid...
  ├─ Disk Image name will be 'Install_macOS_%VERSION%-%BUILD%.dmg'...
┌────────┐
│ SEARCH │
└────────┘
  ├─ Searching for macOS download '12'...
  ├─ Found [012-06873] macOS Monterey 12.4 (21F79) [2022-05-24]
┌───────┐
│ SETUP │
└───────┘
  ├─ Creating new temporary directory '/private/tmp/com.ninxsoft.mist/012-06873'...
┌──────────┐
│ DOWNLOAD │
└──────────┘
  ├─ [ 1 / 7 ] 012-06873.English.dist.......... [ 07.83 KB / 07.83 KB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 2 / 7 ] BuildManifest.plist............. [ 02.07 MB / 02.07 MB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 3 / 7 ] Info.plist...................... [ 05.17 KB / 05.17 KB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 4 / 7 ] InstallAssistant.pkg............ [ 12.10 GB / 12.10 GB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 5 / 7 ] InstallInfo.plist............... [  0188  B /  0188  B (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 6 / 7 ] MajorOSInfo.pkg................. [ 01.29 MB / 01.29 MB (100.0%) ]
  │            Verifying... ✓✓✓
  ├─ [ 7 / 7 ] UpdateBrain.zip................. [ 03.19 MB / 03.19 MB (100.0%) ]
  │            Verifying... ✓✓✓
┌─────────┐
│ INSTALL │
└─────────┘
  ├─ Creating new installer '/Applications/Install macOS Monterey.app'...
  ├─ Created new installer '/Applications/Install macOS Monterey.app'
┌────────────┐
│ DISK IMAGE │
└────────────┘
  ├─ Creating new temporary directory '/private/tmp/com.ninxsoft.mist/012-06873/image'...
  ├─ Copying '/Applications/Install macOS Monterey.app' to '/private/tmp/com.ninxsoft.mist/012-06873/image/Install macOS Monterey.app'...
  ├─ Deleting old image '/Users/Shared/Mist/12.4/21F79/Install_macOS_12.4-21F79.dmg'...
  ├─ Creating image '/Users/Shared/Mist/12.4/21F79/Install_macOS_12.4-21F79.dmg'...
  ├─ Deleting temporary directory '/private/tmp/com.ninxsoft.mist/012-06873/image'...
  ├─ Created image '/Users/Shared/Mist/12.4/21F79/Install_macOS_12.4-21F79.dmg'
┌──────────┐
│ TEARDOWN │
└──────────┘
  └─ Deleting installer '/Applications/Install macOS Monterey.app'...
2022-05-31 13:30:03.199 mist[79988:46383390] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (__SwiftValue)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001ac495198 __exceptionPreprocess + 240
    1   libobjc.A.dylib                     0x00000001ac1dfe04 objc_exception_throw + 60
    2   Foundation                          0x00000001ad34bafc _writeJSONValue + 836
    3   Foundation                          0x00000001ad370bf8 ___writeJSONArray_block_invoke + 260
    4   CoreFoundation                      0x00000001ac407eb8 __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    5   CoreFoundation                      0x00000001ac40c504 __NSArrayEnumerate + 452
    6   Foundation                          0x00000001ad370a28 _writeJSONArray + 356
    7   Foundation                          0x00000001ad34c480 ___writeJSONObject_block_invoke + 388
    8   Foundation                          0x00000001ad34bedc _writeJSONObject + 912
    9   Foundation                          0x00000001ad34c480 ___writeJSONObject_block_invoke + 388
    10  Foundation                          0x00000001ad34bedc _writeJSONObject + 912
    11  Foundation                          0x00000001ad527bb4 -[_NSJSONWriter dataWithRootObject:options:] + 88
    12  Foundation                          0x00000001ad34b680 +[NSJSONSerialization dataWithJSONObject:options:error:] + 120
    13  mist                                0x00000001025e4450 $sSD4mistSSRszrlE10jsonStringSSyKF + 336
    14  mist                                0x00000001025a2234 $s4mist24DownloadInstallerCommandV6export33_137C1A1F312329E8756E7E02C804A799LL_7optionsyAA7ProductV_AA0bC7OptionsVtKFZ + 1912
    15  mist                                0x000000010259d1a8 $s4mist24DownloadInstallerCommandV3run7optionsyAA0bC7OptionsV_tKFZ + 2012
    16  mist                                0x00000001025a5634 $s4mist24DownloadInstallerCommandV3runyyKF + 296
    17  mist                                0x00000001025a7ee0 $s4mist24DownloadInstallerCommandV14ArgumentParser08ParsableD0AadEP3runyyKFTW + 16
    18  mist                                0x000000010263da3c $s14ArgumentParser15ParsableCommandPAAE4mainyySaySSGSgFZ + 144
    19  mist                                0x000000010263daf4 $s14ArgumentParser15ParsableCommandPAAE4mainyyFZ + 52
    20  mist                                0x000000010257fc08 main + 36
    21  dyld                                0x0000000102bc508c start + 520
)
libc++abi: terminating with uncaught exception of type NSException
ninxsoft commented 2 years ago

Nice pickup! Turns out the DownloadOutputType enum was not being transformed to an array of strings correctly, hence the JSON export was freaking out.

Simple one-line fix: 3638cff

Good thing I recently added --cache-downloads, saved me a tonne of time diagnosing the issue 😅

n8felton commented 2 years ago

3638cff works for me, thanks!