Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash with build_report #4

Open
headmin opened this issue Mar 30, 2018 · 1 comment
Open

crash with build_report #4

headmin opened this issue Mar 30, 2018 · 1 comment

Comments

@headmin
Copy link
Collaborator

headmin commented Mar 30, 2018

Hey Tim,

long since we both worked on this. I recently noticed a crash using brew-stew when it's going to build the report file.

On line 287 when it's filling dict with json.loads it just crashes:

the traceback:

Traceback (most recent call last):
  File "./brew-stew", line 366, in <module>
    main()
  File "./brew-stew", line 362, in main
    env.build_report()
  File "./brew-stew", line 287, in build_report
    santa_json = dict(json.loads(santa_out))
ValueError: dictionary update sequence element #0 has length 6; 2 is required

the affected lines:

# line 287-288:
santa_json = dict(json.loads(santa_out))
f['santa_info'].append(santa_json)

However, now quick caveman debugging here, just remove the dict(), then try again and now a report gets written to json file successfully again. Works nearly as before, at least the resulting json file looks like a valid mix of brew info --json=v1 --installed and santactl fileinfo output.

caveman test:

# line 287:
santa_json = json.loads(santa_out)
f['santa_info'].append(santa_json)

Funny thing is the original version worked so well under macOS 10.12.x . I have not (yet) tested brew-stew again in 10.12.6 Sierra.
I'm unsure why overloading the dict() suddenly become an issue under macOS 10.13.3 / 10.13.4 but has not hit us in 10.12.6.

Just in case dict() loading is not urgently required, I tested a write of santa_out directly i.e. f['santa_info'].append(santa_out) would work of course.

Any ideas ? What do you think ?

@timsutton
Copy link
Owner

I had missed this issue altogether and ran into this today, and quickly addressed it in 449b8d6.

Although if we actually have different output on 10.13 than 10.12 (and the JSON output difference isn't from a santa version upgrade like I had thought), then probably the better way would be to examine its content and determine whether it is an array or a dictionary, and just to the consistent thing across both OSes. I don't have a 10.12 VM handy here to test with at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants