mas-cli / mas

:package: Mac App Store command line interface
MIT License
10.93k stars 275 forks source link

`upgrade` unable to parse response json #493

Closed brokosz closed 2 hours ago

brokosz commented 1 year ago

Your Environment

mas Install Method

Describe the Bug

Getting Error: Unable to parse response JSON checking for updates

To Reproduce

mas upgrade will throw the error every time

Expected Behavior

upgrades should work?

Actual Behavior

❯ mas upgrade
Error: Unable to parse response JSON
brokosz commented 6 months ago

I'm still having this issue. I assume MAS is no longer supported? Are there any viable alternatives?

Goralive commented 2 months ago

I got the same issue, but after mas outdated I was able to mas upgrade I hope it's helps

rgoldberg commented 2 months ago

Is this still occurring?

If so, please provide the outputs of both:

$ mas outdated
$ mas list
Goralive commented 2 months ago

For me, it's not reproducible anymore 😫 . But it was reproduced on the first install. After I used mas outdated I was able to do mas upgrade without any errors. I will try to repro on another Mac I have.

Here is the list of app

1274495053  Microsoft To Do       (2.128)
1278508951  Trello                (2.15.0)
497799835   Xcode                 (15.4)
948660805   AusweisApp            (2.2.0)
1485052491  Dropzone 4            (4.80.19)
1595464182  MonitorControlLite    (1.0.0)
1120214373  Battery Health 2      (1.94)
1452453066  Hidden Bar            (1.8)
462058435   Microsoft Excel       (16.88)
585829637   Todoist               (9.7.0)
985367838   Microsoft Outlook     (16.88.1)
462054704   Microsoft Word        (16.88)
1291898086  Toggl Track           (10.3.1)
937984704   Amphetamine           (5.3.2)
1352778147  Bitwarden             (2024.8.1)
462062816   Microsoft PowerPoint  (16.88.1)
rgoldberg commented 2 months ago

@Goralive Thanks. After some other issues are fixed, we should try to provide better error output from mas.

For unparsable JSON errors, we should output the unparsable JSON after the error message so that we can investigate more easily. If the JSON is very long, maybe the JSON should be output only if a new --debug option is supplied; we can add a note about --debug in the error message.

Goralive commented 2 months ago

yeah, it would be really great 💯 to have in the output this option.

So I have installed it on other MacBooks, but all the stuff is up to date... So for me can't reproduce. Maybe @brokosz have a steps

brokosz commented 2 months ago

I gave up on mas due to the errors, but let me try again today. I'll post output here as well when I get into the office.

rgoldberg commented 2 months ago

@brokosz Thanks

brokosz commented 2 months ago

yay - success!

[brokosz@ ~]$ mas version
1.8.6
[brokosz@ ~]$ mas outdated
Warning: Identifier 1502527999 not found in store. Was expected to identify Jiffy.
Warning: Identifier 445189367 not found in store. Was expected to identify PopClip.
Warning: Identifier 688211836 not found in store. Was expected to identify EasyRes.
Warning: Identifier 1514817810 not found in store. Was expected to identify Poolsuite FM.
545519333 Prime Video (10.34 -> 10.39.2)
6449440582 Sparrow (2.5 -> 12)
302584613 Kindle (7.18 -> 7.18.1)
1444636541 Photomator (3.3.23 -> 3.3.24)
6447647340 S3 (2024.32 -> 2024.33)
1589391989 Mapper (3.0.1 -> 3.0.2)
[brokosz@ ~]$ mas upgrade
Upgrading 6 outdated applications:
Prime Video (10.34), Sparrow (2.5), Kindle (7.18), Mapper (3.0.1), Photomator (3.3.23), S3 (2024.32)
==> Downloading Amazon Prime Video
==> Installed Amazon Prime Video
==> Downloading Sparrow Weather
==> Installed Sparrow Weather
==> Installed Amazon Kindle
==> Downloading Mapper for Safari
==> Installed Mapper for Safari
==> Downloading Photomator – Photo Editor
==> Installed Photomator – Photo Editor
==> Downloading S3: Storage & Files
==> Installed S3: Storage & Files
rgoldberg commented 2 months ago

Looks like the immediate reaction should be to output the unparsable JSON. Once that's in place, if anyone experiences the same problem, then we'll be able to investigate better. But there won't be much else that can be done until someone else encounters the same error.

kbd commented 2 months ago

I've been getting the same error and also can't help diagnose because mas doesn't output the json. Imo it shouldn't be behind a debug flag because it's an error.

Fwiw, it seems to be related to the Amazon Kindle app.

mas "Amazon Kindle", id: 302584613

The problem started when I added Kindle to my Brewfile, and commenting out that line in my Brewfile fixed it. Plus I see someone above has Kindle installed as well.

The app is doing something weird where it's always thinking it needs updating, so it may be related to that.

rgoldberg commented 2 months ago

@kbd I installed 'Amazon Kindle' 302584613 from the Mac App Store GUI.

I do not get any errors from mas update when it's installed.

I haven't used Brewfiles directly, so maybe the issue is with installing using a Brewfile or using mas install.

I'm running macOS 12.7.6 on Intel. I tried a few different versions of mas, none of which output any errors.

rgoldberg commented 3 weeks ago

@kbd @brokosz @Goralive @joshuaclayton The code in the GitHub main branch should output to stderr responses that aren't parseable as JSON. There are many other fixes in main. The fixes are not in any of the released betas, nor are they in any released stable versions. We are waiting on @phatblat's new automated release process to publish new versions.

Can you first try to replicate the problem with the existing mas stable version 1.8.6? It won't display any response that isn't parsable as JSON, but it will let us know if the problem still exists on 1.8.6z

Then can you test what's in main by installing it via Homebrew by:

brew install --HEAD mas

That will let us see if the problem was luckily fixed by any of the many changes in main, and will let us see the unparsable response if the problem wasn't fixed in main.

Thanks for any help investigating this issue.

Goralive commented 3 weeks ago

@rgoldberg I have updated to 1.8.7-beta.8 But I didn't notice the issue for a while. That was a one-timer for me. If I notice something I will let you know. Thanks for the tool 🫶

rgoldberg commented 3 weeks ago

@Goralive Thanks for checking.

Glad no issue right now, but if anything occurs again, please let us know.

brokosz commented 3 weeks ago

same - no issues for me right now either. 🤞🏼

rgoldberg commented 3 weeks ago

@brokosz Thanks for the info. Please let us know whenever you experience the problem again.

johnhampton commented 14 hours ago

I received Error: Unable to parse response as JSON when running mas search Sessions. I'm using mas version 1.8.7. I've attached the json output for reference.

mas.json

rgoldberg commented 2 hours ago

@johnhampton Thanks for the error output.

Your parsing error was caused by one search result app missing the price & formattedPrice properties.

The existing JSON parsing is brittle. In my PR for this (#643), these 2 properties are now optional instead of required.

The future Output Refactor (#626) will completely revamp how we handle JSON, so missing other properties won't cause any problems when that is done, but that won't be worked on / completed for some time.

In the meantime, #643 has been merged into the main branch & has closed out this issue.

It won't be released to the public until the next mas version release (presumably 1.8.8), which might take a few weeks. You can test it out (as long as you have Xcode 14.2+ so you can build mas from source) by installing mas from the main branch by running:

brew uninstall mas
brew install --HEAD mas

If you still experience the error, please let us know.

If anyone experiences any other parsing issues, please open a new issue (and please try the code from main as instructed above to ensure that your parsing issues hasn't already been solved).