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

ValueError: too many values to unpack (expected 2) when using SlackPostCurl PostProcessor #7

Closed
ggeerraalldd opened this issue Sep 1, 2022 · 15 comments

Comments

@ggeerraalldd
Copy link

I'm trying out the new SlackPostCurl PostProcessor, and so far it is working but reports an error for each successful Slack post.
Both AutoPkg 2.7 (with Python 3.10) and AutoPkg 2.4.1 (with Python 3.7) have this error. I'm using the PostProcessor as is, with no edits.

To test, I ran an AutoPkg recipe from Terminal (my slack webhook is redacted):

$ autopkg run -vvv Skype.munki --post="com.github.notverypc.autopkg-recipes.postprocessors/SlackPostCurl" --key "webhook_url"="https://hooks.slack.com/services/123456789/123456789/123456789"

A Skype update was available, so it was downloaded and added to my repo. I received a Slack post:

SlackPostCurl_repo_adds

In Terminal at the end of the AutoPkg run was this error:

           'munki_repo_changed': True,
           'webhook_url': 'https://hooks.slack.com/services/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'}}
SlackPostCurl: No value supplied for slack_icon_url, setting default value of: 
SlackPostCurl: No value supplied for slack_username, setting default value of: AutoPKG
SlackPostCurl: Slack webhook post attempt 1
Traceback (most recent call last):
  File "/Library/AutoPkg/autopkglib/__init__.py", line 1016, in process
    self.env = processor.process()
  File "/Library/AutoPkg/autopkglib/__init__.py", line 802, in process
    self.main()
  File "/Users/shorty/Library/AutoPkg/RecipeRepos/com.github.notverypc.autopkg-recipes/PostProcessors/SlackPostCurl.py", line 142, in main
    ) = self.execute_curl(curl_cmd)
ValueError: too many values to unpack (expected 2)
  File "/Library/AutoPkg/autopkglib/__init__.py", line 1016, in process
    self.env = processor.process()
too many values to unpack (expected 2)
Failed.
Receipt written to /Users/shorty/Library/AutoPkg/Cache/local.munki.Skype/receipts/Skype-receipt-20220901-160005.plist

The following recipes failed:
    Skype.munki
        Error in local.munki.Skype: Processor: com.github.notverypc.autopkg-recipes.postprocessors/SlackPostCurl: Error: too many values to unpack (expected 2)

Despite the error, Skype was added to the repo.

I also use autopkg-conductor.sh set up with SlackPostCurl for timed runs, which does error collecting to post to Slack at the end of a recipe list run. The same error gets reported to Slack like this:

SlackPostCurl_autopkg-conductor_errors

Full AutoPkg run results attached:

AutoPkg-2.4.1-run.txt
AutoPkg-2.7-run.txt

@notverypc
Copy link
Owner

What happens if you change the command from:

autopkg run -vvv Skype.munki --post="com.github.notverypc.autopkg-recipes.postprocessors/SlackPostCurl" --key "webhook_url"="https://hooks.slack.com/services/123456789/123456789/123456789"

To, without the "" around webhook_url:

autopkg run -vvv Skype.munki --post="com.github.notverypc.autopkg-recipes.postprocessors/SlackPostCurl" --key webhook_url="https://hooks.slack.com/services/123456789/123456789/123456789"

@ggeerraalldd
Copy link
Author

Changing the quoting made no difference.

@notverypc
Copy link
Owner

🤔 Can you add the channel key to the command - even if you're not overriding it.

autopkg run -Skype.munki -post="com.github.notverypc.autopkg-recipes.postprocessors/SlackPostCurl" --key webhook_url="https://hooks.slack.com/services/XXXXXXX" --key slack_channel="testing"

@ggeerraalldd
Copy link
Author

ggeerraalldd commented Sep 2, 2022

Same error, but it did not post to Slack (no 'testing' channel)
The webhook_url I use points directly to my user in Slack.

           'slack_channel': 'testing',
           'webhook_url': 'https://hooks.slack.com/services/123456789/123456789/123456789'}}
SlackPostCurl: No value supplied for slack_icon_url, setting default value of: 
SlackPostCurl: No value supplied for slack_username, setting default value of: AutoPKG
SlackPostCurl: Slack webhook post attempt 1
Traceback (most recent call last):
  File "/Library/AutoPkg/autopkglib/__init__.py", line 1016, in process
    self.env = processor.process()
  File "/Library/AutoPkg/autopkglib/__init__.py", line 802, in process
    self.main()
  File "/Users/shorty/Library/AutoPkg/RecipeRepos/com.github.notverypc.autopkg-recipes/PostProcessors/SlackPostCurl.py", line 145, in main
    ) = self.execute_curl(curl_cmd)
ValueError: too many values to unpack (expected 2)
  File "/Library/AutoPkg/autopkglib/__init__.py", line 1016, in process
    self.env = processor.process()
too many values to unpack (expected 2)
Failed.
Receipt written to /Users/shorty/Library/AutoPkg/Cache/local.munki.Skype/receipts/Skype-receipt-20220902-083227.plist```

@notverypc
Copy link
Owner

Can you post the command you used and I'll look into it further.
"The webhook_url I use points directly to my user in Slack." Are you posting direct to you not a channel?

@ggeerraalldd
Copy link
Author

autopkg run -vvv Skype.munki --post="com.github.notverypc.autopkg-recipes.postprocessors/SlackPostCurl" --key webhook_url="https://hooks.slack.com/services/123456789/123456789/123456789" --key slack_channel="testing"

I am posting directly to myself and not a channel. I've used that webhook_url with AutoPkgr and your original Slacker post processor (which still works).

@notverypc
Copy link
Owner

Thanks - I'll have a look into this.
I managed to reproduce the error when I just used the webhook_url but after adding slack_channel it ran without errors.

I'll have a proper dig, probs something simple that I've missed.

@ggeerraalldd
Copy link
Author

I went in to Slack settings and changed my webhook URL from a deprecated Custom Integration I set up in 2018 to one generated by the more recent Slack App method. That also made no difference.

@notverypc
Copy link
Owner

I've updated the postprocessor and it should resolve your issue 🤞

@ggeerraalldd
Copy link
Author

I think that's closer, but I'm still getting an error. This time, it appears the error is for every recipe that doesn't have an update, so doesn't post to slack:

local variable 'json_data' referenced before assignment
Failed.

From a AutoPkg list of 61 recipes, 2 had updates and I received the error 59 times. That includes MakeCatalogs.munki recipe that runs at the end, and will never result in a download.

Attached are AutoPkg results of two consecutive runs, the first finds updates for the two recipes and posts to Slack without error, then the next run has no updates and errors out twice.
2-recipesWithNoUpdates-run.txt
1-recipesWithUpdates-run.txt

@notverypc
Copy link
Owner

🤬 My bad - I'll dig into it in the morning- Sorry 🙏

@notverypc
Copy link
Owner

Should be working now - sorry for all the pain 🙏

@ggeerraalldd
Copy link
Author

That ran error free on my AutoPkg test server. I changed my production server to use SlackPostCurl instead of Slacker so I'll see what happens on its next scheduled run.

@ggeerraalldd
Copy link
Author

The full recipe list on my production server ran via autopkg-conductor.sh using SlackPostCurl as the post processor, and worked as expected!

Thank you so much for the bug fix. I appreciate all your effort. :)

@notverypc
Copy link
Owner

Pleased to hear it's working :)
Sorry for the pain :)

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