Informatics Virtual Learning Environment

Console crashes on startup with KeyError: 'PATH' for os.environ

Reported by David Coles on 2010-02-28
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IVLE
Critical
David Coles
1.0
Undecided
Unassigned

Bug Description

IVLE intermitantly crashes when starting up the console. This appears to be an issue with ivle.interpret.execute_raw assuming that it will always have a PATH environment variable available.

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/ivle/dispatch/__init__.py", line 164, in handler
    view.render(req)
  File "/usr/lib/python2.5/site-packages/ivle/webapp/base/rest.py", line 141, in render
    outjson = op(req, **opargs)
  File "/usr/lib/python2.5/site-packages/ivle/webapp/console/service.py", line 54, in start
    working_dir)
  File "/usr/lib/python2.5/site-packages/ivle/console.py", line 128, in __init__
    self.restart()
  File "/usr/lib/python2.5/site-packages/ivle/console.py", line 165, in restart
    self.working_dir, "/usr/bin/python", args)
  File "/usr/lib/python2.5/site-packages/ivle/interpret.py", line 450, in execute_raw
    'PATH': os.environ['PATH'],
  File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
    raise KeyError(key)
KeyError: 'PATH'

Solution is probably to hard code PATH to "/bin:/usr/bin:/usr/local/bin"

Related branches

William Grant (wgrant) wrote :

This happened locally just before release, but an Apache restart fixed it. It's now happening on informatics7.

We should fix this on two levels:
 - We should hardcode PATH.
 - We should prevent ivle.interpret from mutating os.environ; subprocess.Popen takes an "env" argument.

David Coles (dcoles) wrote :

Fixed in r1776 and r1777. Use a hard coded path for ivle.interpret.execute_raw and use set up a sanitized environment that we pass to subprocess.Popen for ivle.execute_cgi.

Changed in ivle:
status: Triaged → Fix Committed
Matt Giuca (mgiuca) wrote :

Why is there a separate bug status for milestone 1.0?

William Grant (wgrant) wrote :

It's actually a separate task for the 1.0 *series*, since David misunderstood the rather confusing "Target to release" UI. That's generally used for requesting a backport to a maintenance series, but we don't use multiple series (yet).

David Coles (dcoles) wrote :

Released in 1.0.1

Changed in ivle:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers