valnet / valuenetwork

Resource Planning and Value Accounting for Value Networks
http://mikorizal.org
GNU Affero General Public License v3.0
99 stars 25 forks source link

Error in creating workflow recipe #403

Open fosterlynn opened 9 years ago

fosterlynn commented 9 years ago

Trace below. Not sure of condition. Creating a workflow recipe, had already added one or two process types with a work input.

Internal Server Error: /accounting/edit-stream-recipe/2/

Traceback (most recent call last):

File "/home/commons/webapps/django/lib/python2.7/django/core/handlers/base.py", line 109, in get_response response = callback(request, _callback_args, *_callback_kwargs)

File "/home/commons/webapps/django/lib/python2.7/django/contrib/auth/decorators.py", line 20, in _wrapped_view return view_func(request, _args, *_kwargs)

File "/home/commons/webapps/django/valuenetwork/valuenetwork/valueaccounting/views.py", line 1510, in edit_stream_recipe process_types, inheritance = rt.staged_process_type_sequence()

File "/home/commons/webapps/django/valuenetwork/valuenetwork/valueaccounting/models.py", line 1727, in staged_process_type_sequence stages, inheritance = self.staged_commitment_type_sequence()

File "/home/commons/webapps/django/valuenetwork/valuenetwork/valueaccounting/models.py", line 1666, in staged_commitment_type_sequence event_type=creation_et)

File "/home/commons/webapps/django/lib/python2.7/django/db/models/manager.py", line 131, in get return self.get_query_set().get(_args, *_kwargs)

File "/home/commons/webapps/django/lib/python2.7/django/db/models/query.py", line 368, in get % (self.model._meta.object_name, num, kwargs))

MultipleObjectsReturned: get() returned more than one ProcessTypeResourceType -- it returned 2! Lookup parameters were {'event_type': , 'stage__isnull': False}

<WSGIRequest path:/accounting/edit-stream-recipe/2/, GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{'csrftoken': 'l0aTsvIj6rrnangghsVxjJskvLXijJQi', 'sessionid': '983c70f857e2690d953d2c1fb2b5c49c'}, META:{'CSRF_COOKIE': 'l0aTsvIj6rrnangghsVxjJskvLXijJQi', 'DOCUMENT_ROOT': '/usr/local/apache2/htdocs', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTPACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/_;q=0.8', 'HTTP_ACCEPT_ENCODING': 'gzip', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', 'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_CONNECTION': 'close', 'HTTP_COOKIE': 'sessionid=983c70f857e2690d953d2c1fb2b5c49c; csrftoken=l0aTsvIj6rrnangghsVxjJskvLXijJQi', 'HTTP_FORWARDED_REQUEST_URI': '/accounting/edit-stream-recipe/2/', 'HTTP_HOST': 'commons.webfactional.com', 'HTTP_HTTPS': 'off', 'HTTP_HTTP_X_FORWARDED_PROTO': 'http', 'HTTP_REFERER': 'http://commons.webfactional.com/accounting/edit-stream-recipe/2/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36', 'HTTP_X_FORWARDED_FOR': '104.160.204.194', 'HTTP_X_FORWARDED_HOST': 'commons.webfactional.com', 'HTTP_X_FORWARDED_PROTO': 'http', 'HTTP_X_FORWARDED_SERVER': 'commons.webfactional.com', 'HTTP_X_FORWARDED_SSL': 'off', 'PATH_INFO': u'/accounting/edit-stream-recipe/2/', 'PATH_TRANSLATED': '/home/commons/webapps/django/valuenetwork/valuenetwork/wsgi.py/accounting/edit-stream-recipe/2/', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '34772', 'REQUEST_METHOD': 'GET', 'REQUEST_URI': '/accounting/edit-stream-recipe/2/', 'SCRIPT_FILENAME': '/home/commons/webapps/django/valuenetwork/valuenetwork/wsgi.py', 'SCRIPT_NAME': u'', 'SERVER_ADDR': '127.0.0.1', 'SERVER_ADMIN': '[no address given]', 'SERVER_NAME': 'commons.webfactional.com', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.0', 'SERVER_SIGNATURE': '', 'SERVER_SOFTWARE': 'Apache/2.2.25 (Unix) mod_wsgi/3.5 Python/2.7.9', 'mod_wsgi.application_group': 'web371.webfaction.com|', 'mod_wsgi.callable_object': 'application', 'mod_wsgi.enable_sendfile': '0', 'mod_wsgi.handler_script': '', 'mod_wsgi.input_chunked': '0', 'mod_wsgi.listener_host': '', 'mod_wsgi.listener_port': '24815', 'mod_wsgi.process_group': 'django', 'mod_wsgi.queue_start': '1435883566373079', 'mod_wsgi.request_handler': 'wsgi-script', 'mod_wsgi.script_reloading': '1', 'mod_wsgi.version': (3, 5), 'wsgi.errors': <mod_wsgi.Log object at 0x7f68d548a970>, 'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f68d57958a0>, 'wsgi.input': <mod_wsgi.Input object at 0x7f68d548a870>, 'wsgi.multiprocess': True, 'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}>

bhaugen commented 9 years ago

The problem was duplicate CommitmentTypes (ProcessTypeResourceTypes): both had the Create Changeable EventType and a stage. The code expected one and only one.

I deleted the dup. This might be similar to that Maintain Associations bug, where dups got created via some user flailing.

The code above could handle the situation by using a filter instead of a get and picking the first one it finds, but I think the dup is an error in itself and should be prevented.

bhaugen commented 9 years ago

I marked the location of the bug in https://github.com/valnet/valuenetwork/blob/master/valuenetwork/valueaccounting/models.py#L1665 but it will take a bunch more investigation and thought before fixing.