Signing Python 2 beem scripts stopped working

in #utopian-io6 years ago (edited)

Project Information

Expected behavior

A few days ago my automated @pibarabot posts stopped working. To be precise, the wtw_process_json.py script started crashing at the point where it should be posting the daily report.

The relevant part of the script:

beneficiaries = [{'account':'freezepeach', 'weight':5000},
      {'account':'pibara', 'weight':5000}]
    metafile = join(mypath,"wtw-steem-meta-" + date + ".json")
    postfile = join(mypath,"wtw-" + date + ".MD")
    with open(metafile) as m:
        json_metadata = json.loads(m.read())
    with open(postfile) as p:
        body = p.read()
    s = Steem(keys=fjson.conf["steem-posting-key"], nobroadcast=False)
    subject = "Flag-war stats for posts made on " + date
    tx = s.post(subject, body, author=fjson.conf["steem-account"], 
        tags=["stats","steem","steemit","flags","flagwars"],
        json_metadata=json_metadata, beneficiaries=beneficiaries)

Actual behavior

Instead of posting to the blockchain, the script has been dying with a beem.exceptions.InvalidWifError exception.
As the keys used haven't actually changed, this exception is unexpected.

Looking closer at the bug, I found an other old Python2 script exibiting the same behaviour:

#!/usr/bin/env python2
from beem import Steem
import beem
keys = ["REPLACEWITHEREALKEY1"],["REPLACEWITHREALKEY2"]
s = Steem(keys=keys)
a = beem.account.Account("pibara",steem_instance=s)
delegations = dict();
delegations["mattockfs"] = 1.0593
for account in delegations.keys():
    vests = 1000000*delegations[account]
    a.delegate_vesting_shares(account,vests)

Invocation results in a really long wait, followed by the following output:

As this script is a python version neutral script, it can easily be shown that this problem only occurs with Python 2 by only changing the first line of the script to:

#!/usr/bin/env python3

How to reproduce

The following information might be relevant to reproduction

  • Beem version: 0.20.9
  • Operating system: Ubuntu 18.04.1 LTS
  • Python2 beem scripts that worked perfectly every day for months on end stopped working on the 27th of October.

GitHub Account

Sort:  

Hi @mattocks, have you opened a ticket addressing this issue on the project's github repo?

Thank you for your review, @fego! Keep up the good work!

Hi @mattockfs, thanks for making this contribution.

Thanks to your report, the issue was immediately fixed.

Feedback:

  1. The post title is not as detailed as it should be. Submission title should include the app name and version number, as well as a brief description of the occuring issue ([Product Name] [Product Version] – Succinct description of the bug).

  2. The actual and expected behavior are properly laid out, just so the developer can spot the discrepancy between what is expected and what was currently at play.

  3. I like that you were able to explore and identify the pattern and then note the same behavior in the old python 2 script.

  4. Are you aware that analysing what possibly led to the bug and proposing a fix increases your reward score? Well, you should try that in your next report ;)

  5. One more thing, the sample code you provided should have been in the "how to reproduce section". The testing device type and OS details should then come beneath and under the environment header.

It was a good find and it added significant value to the beem project. I hope this feedback helps in your subsequent reports.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Hey, @mattockfs!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Hi @mattockfs!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Thanks for the detailed error report. I already found the cause and I'm ready to submit the fix. Can you create an issue: https://github.com/holgern/beem/issues ? Then I can link to it.

Coin Marketplace

STEEM 0.15
TRX 0.17
JST 0.028
BTC 69106.80
ETH 2468.44
USDT 1.00
SBD 2.43