Opened 8 years ago

Closed 8 years ago

#52941 closed defect (fixed)

Deleting tags causes webhook to fail with HTTP 500 because trac-github-update hook crashes

Reported by: neverpanic (Clemens Lang) Owned by: admin@…
Priority: Normal Milestone:
Component: server/hosting Version: 2.3.5
Keywords: trac Cc: raimue (Rainer Müller)
Port:

Description

On 2016-11-16, we deleted a tag from the macports-base repository, which caused a webhook to be delivered to our Trac instance. The webhook payload was

{
  "ref": "refs/tags/release_2_3_4",
  "before": "d92ac26f0ce6bad02325c879285598d34beb7a26",
  "after": "0000000000000000000000000000000000000000",
  "created": false,
  "deleted": true,
  "forced": false,
  "base_ref": null,
  "compare": "https://github.com/macports/macports-base/compare/d92ac26f0ce6...000000000000",
  "commits": [],
  ...
}

This webhook was processed correctly, until the trac-github-update hook from the repository was executed, which usually sends change notification mails to the mailing lists. We use git multimail in this hook, which seems to have crashed with a Python exception:

Running hook on macports-base
* Updating clone
* Synchronizing with clone
* Running trac-github-update hook
Traceback (most recent call last):
  File "/var/www/trac/trac-env/plugins/hooks/trac-github-update.py", line 332, in <module>
    main(sys.argv[1:])
  File "/var/www/trac/trac-env/plugins/hooks/trac-github-update.py", line 326, in main
    run_as_github_webhook(environment, mailer)
  File "/var/www/trac/trac-env/plugins/hooks/trac-github-update.py", line 274, in run_as_github_webhook
    timestamp = read_git_output(['log', '--no-walk', '--format=%ct', change.new.sha1])
  File "/var/www/trac/virtualenv/local/lib/python2.7/site-packages/git_multimail.py", line 441, in read_git_output
    return read_output(GIT_CMD + args, input=input, keepends=keepends, **kw)
  File "/var/www/trac/virtualenv/local/lib/python2.7/site-packages/git_multimail.py", line 456, in read_output
    stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kw
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
TypeError: execv() arg 2 must contain only strings
Error: hook failed with exit code 1

Change History (1)

comment:1 Changed 8 years ago by raimue (Rainer Müller)

Resolution: fixed
Status: newclosed

In 26b2922/trac.macports.org:

trac-github-update: fix run error on tag deletions

GitHub will indicate a tag deletion with the special value of
"0000000000000000000000000000000000000000" as new revision. Whenever the
change does not reference a valid new SHA1 hash, use the current
timestamp as fallback.

Closes: #52941

Note: See TracTickets for help on using tickets.