{"action":"created","comment":{"url":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/comments/27671746","id":27671746,"diff_hunk":"@@ -96,10 +96,13 @@ def respond_json(ctx, data, code = None, headers = None, jsonp = None):\n                 for name, value in error.iteritems()\n                 if value is not None\n                 )\n+        if isinstance(error, str):\n+            error = data['error'] = dict(\n+                message = data['error'],\n+                code = 500","path":"openfisca_web_api/wsgihelpers.py","position":16,"original_position":16,"commit_id":"e004f29bb8854cca1caee6e71b1c41b594f91ca5","original_commit_id":"e004f29bb8854cca1caee6e71b1c41b594f91ca5","user":{"login":"MattiSG","id":222463,"avatar_url":"https://avatars.githubusercontent.com/u/222463?v=3","gravatar_id":"","url":"https://api.github.com/users/MattiSG","html_url":"https://github.com/MattiSG","followers_url":"https://api.github.com/users/MattiSG/followers","following_url":"https://api.github.com/users/MattiSG/following{/other_user}","gists_url":"https://api.github.com/users/MattiSG/gists{/gist_id}","starred_url":"https://api.github.com/users/MattiSG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattiSG/subscriptions","organizations_url":"https://api.github.com/users/MattiSG/orgs","repos_url":"https://api.github.com/users/MattiSG/repos","events_url":"https://api.github.com/users/MattiSG/events{/privacy}","received_events_url":"https://api.github.com/users/MattiSG/received_events","type":"User","site_admin":false},"body":"> I don't think it is a good idea to hardcode 500, the code argument of respond_json should be used\r\nThat is the case  ;)\r\nI'm just setting a default for `error['code']`, which is evaluated lines 111-112 as `code = code or error['code']`.\r\n\r\n> I would prefer to add an assertion\r\nIf you have a failing assertion in this part of the code, you will crash and send a text-only `Internal Server Error` response.\r\n\r\nThis patch is not great, but it is what amounted to the least refactor of the existing heuristics in the `if error:` block.","created_at":"2015-04-02T16:10:24Z","updated_at":"2015-04-02T16:10:24Z","html_url":"https://github.com/openfisca/openfisca-web-api/pull/24#discussion_r27671746","pull_request_url":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/comments/27671746"},"html":{"href":"https://github.com/openfisca/openfisca-web-api/pull/24#discussion_r27671746"},"pull_request":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/24","id":32515495,"html_url":"https://github.com/openfisca/openfisca-web-api/pull/24","diff_url":"https://github.com/openfisca/openfisca-web-api/pull/24.diff","patch_url":"https://github.com/openfisca/openfisca-web-api/pull/24.patch","issue_url":"https://api.github.com/repos/openfisca/openfisca-web-api/issues/24","number":24,"state":"open","locked":false,"title":"Improve wsgihelpers resilience","user":{"login":"MattiSG","id":222463,"avatar_url":"https://avatars.githubusercontent.com/u/222463?v=3","gravatar_id":"","url":"https://api.github.com/users/MattiSG","html_url":"https://github.com/MattiSG","followers_url":"https://api.github.com/users/MattiSG/followers","following_url":"https://api.github.com/users/MattiSG/following{/other_user}","gists_url":"https://api.github.com/users/MattiSG/gists{/gist_id}","starred_url":"https://api.github.com/users/MattiSG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MattiSG/subscriptions","organizations_url":"https://api.github.com/users/MattiSG/orgs","repos_url":"https://api.github.com/users/MattiSG/repos","events_url":"https://api.github.com/users/MattiSG/events{/privacy}","received_events_url":"https://api.github.com/users/MattiSG/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-02T14:21:43Z","updated_at":"2015-04-02T16:10:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c566e4745d33670fc2aaf3918cf9b6ae3d583df","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/24/commits","review_comments_url":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/24/comments","review_comment_url":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openfisca/openfisca-web-api/issues/24/comments","statuses_url":"https://api.github.com/repos/openfisca/openfisca-web-api/statuses/e004f29bb8854cca1caee6e71b1c41b594f91ca5","head":{"label":"sgmap:improve-wsgihelpers-resilience","ref":"improve-wsgihelpers-resilience","sha":"e004f29bb8854cca1caee6e71b1c41b594f91ca5","user":{"login":"sgmap","id":7874148,"avatar_url":"https://avatars.githubusercontent.com/u/7874148?v=3","gravatar_id":"","url":"https://api.github.com/users/sgmap","html_url":"https://github.com/sgmap","followers_url":"https://api.github.com/users/sgmap/followers","following_url":"https://api.github.com/users/sgmap/following{/other_user}","gists_url":"https://api.github.com/users/sgmap/gists{/gist_id}","starred_url":"https://api.github.com/users/sgmap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgmap/subscriptions","organizations_url":"https://api.github.com/users/sgmap/orgs","repos_url":"https://api.github.com/users/sgmap/repos","events_url":"https://api.github.com/users/sgmap/events{/privacy}","received_events_url":"https://api.github.com/users/sgmap/received_events","type":"Organization","site_admin":false},"repo":{"id":28633089,"name":"openfisca-web-api","full_name":"sgmap/openfisca-web-api","owner":{"login":"sgmap","id":7874148,"avatar_url":"https://avatars.githubusercontent.com/u/7874148?v=3","gravatar_id":"","url":"https://api.github.com/users/sgmap","html_url":"https://github.com/sgmap","followers_url":"https://api.github.com/users/sgmap/followers","following_url":"https://api.github.com/users/sgmap/following{/other_user}","gists_url":"https://api.github.com/users/sgmap/gists{/gist_id}","starred_url":"https://api.github.com/users/sgmap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgmap/subscriptions","organizations_url":"https://api.github.com/users/sgmap/orgs","repos_url":"https://api.github.com/users/sgmap/repos","events_url":"https://api.github.com/users/sgmap/events{/privacy}","received_events_url":"https://api.github.com/users/sgmap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sgmap/openfisca-web-api","description":"Web API for OpenFisca -- a versatile microsimulation free software","fork":true,"url":"https://api.github.com/repos/sgmap/openfisca-web-api","forks_url":"https://api.github.com/repos/sgmap/openfisca-web-api/forks","keys_url":"https://api.github.com/repos/sgmap/openfisca-web-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sgmap/openfisca-web-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sgmap/openfisca-web-api/teams","hooks_url":"https://api.github.com/repos/sgmap/openfisca-web-api/hooks","issue_events_url":"https://api.github.com/repos/sgmap/openfisca-web-api/issues/events{/number}","events_url":"https://api.github.com/repos/sgmap/openfisca-web-api/events","assignees_url":"https://api.github.com/repos/sgmap/openfisca-web-api/assignees{/user}","branches_url":"https://api.github.com/repos/sgmap/openfisca-web-api/branches{/branch}","tags_url":"https://api.github.com/repos/sgmap/openfisca-web-api/tags","blobs_url":"https://api.github.com/repos/sgmap/openfisca-web-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sgmap/openfisca-web-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sgmap/openfisca-web-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/sgmap/openfisca-web-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sgmap/openfisca-web-api/statuses/{sha}","languages_url":"https://api.github.com/repos/sgmap/openfisca-web-api/languages","stargazers_url":"https://api.github.com/repos/sgmap/openfisca-web-api/stargazers","contributors_url":"https://api.github.com/repos/sgmap/openfisca-web-api/contributors","subscribers_url":"https://api.github.com/repos/sgmap/openfisca-web-api/subscribers","subscription_url":"https://api.github.com/repos/sgmap/openfisca-web-api/subscription","commits_url":"https://api.github.com/repos/sgmap/openfisca-web-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/sgmap/openfisca-web-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/sgmap/openfisca-web-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/sgmap/openfisca-web-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/sgmap/openfisca-web-api/contents/{+path}","compare_url":"https://api.github.com/repos/sgmap/openfisca-web-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sgmap/openfisca-web-api/merges","archive_url":"https://api.github.com/repos/sgmap/openfisca-web-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sgmap/openfisca-web-api/downloads","issues_url":"https://api.github.com/repos/sgmap/openfisca-web-api/issues{/number}","pulls_url":"https://api.github.com/repos/sgmap/openfisca-web-api/pulls{/number}","milestones_url":"https://api.github.com/repos/sgmap/openfisca-web-api/milestones{/number}","notifications_url":"https://api.github.com/repos/sgmap/openfisca-web-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sgmap/openfisca-web-api/labels{/name}","releases_url":"https://api.github.com/repos/sgmap/openfisca-web-api/releases{/id}","created_at":"2014-12-30T14:11:42Z","updated_at":"2015-04-02T09:55:28Z","pushed_at":"2015-04-02T15:28:51Z","git_url":"git://github.com/sgmap/openfisca-web-api.git","ssh_url":"git@github.com:sgmap/openfisca-web-api.git","clone_url":"https://github.com/sgmap/openfisca-web-api.git","svn_url":"https://github.com/sgmap/openfisca-web-api","homepage":null,"size":541,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"prod"}},"base":{"label":"openfisca:next","ref":"next","sha":"696d6e95d6c27e0d300a65b70bc3965278a22dd2","user":{"login":"openfisca","id":1794404,"avatar_url":"https://avatars.githubusercontent.com/u/1794404?v=3","gravatar_id":"","url":"https://api.github.com/users/openfisca","html_url":"https://github.com/openfisca","followers_url":"https://api.github.com/users/openfisca/followers","following_url":"https://api.github.com/users/openfisca/following{/other_user}","gists_url":"https://api.github.com/users/openfisca/gists{/gist_id}","starred_url":"https://api.github.com/users/openfisca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfisca/subscriptions","organizations_url":"https://api.github.com/users/openfisca/orgs","repos_url":"https://api.github.com/users/openfisca/repos","events_url":"https://api.github.com/users/openfisca/events{/privacy}","received_events_url":"https://api.github.com/users/openfisca/received_events","type":"Organization","site_admin":false},"repo":{"id":15510373,"name":"openfisca-web-api","full_name":"openfisca/openfisca-web-api","owner":{"login":"openfisca","id":1794404,"avatar_url":"https://avatars.githubusercontent.com/u/1794404?v=3","gravatar_id":"","url":"https://api.github.com/users/openfisca","html_url":"https://github.com/openfisca","followers_url":"https://api.github.com/users/openfisca/followers","following_url":"https://api.github.com/users/openfisca/following{/other_user}","gists_url":"https://api.github.com/users/openfisca/gists{/gist_id}","starred_url":"https://api.github.com/users/openfisca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openfisca/subscriptions","organizations_url":"https://api.github.com/users/openfisca/orgs","repos_url":"https://api.github.com/users/openfisca/repos","events_url":"https://api.github.com/users/openfisca/events{/privacy}","received_events_url":"https://api.github.com/users/openfisca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openfisca/openfisca-web-api","description":"Web API for OpenFisca -- a versatile microsimulation free software","fork":false,"url":"https://api.github.com/repos/openfisca/openfisca-web-api","forks_url":"https://api.github.com/repos/openfisca/openfisca-web-api/forks","keys_url":"https://api.github.com/repos/openfisca/openfisca-web-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openfisca/openfisca-web-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openfisca/openfisca-web-api/teams","hooks_url":"https://api.github.com/repos/openfisca/openfisca-web-api/hooks","issue_events_url":"https://api.github.com/repos/openfisca/openfisca-web-api/issues/events{/number}","events_url":"https://api.github.com/repos/openfisca/openfisca-web-api/events","assignees_url":"https://api.github.com/repos/openfisca/openfisca-web-api/assignees{/user}","branches_url":"https://api.github.com/repos/openfisca/openfisca-web-api/branches{/branch}","tags_url":"https://api.github.com/repos/openfisca/openfisca-web-api/tags","blobs_url":"https://api.github.com/repos/openfisca/openfisca-web-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openfisca/openfisca-web-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openfisca/openfisca-web-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/openfisca/openfisca-web-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openfisca/openfisca-web-api/statuses/{sha}","languages_url":"https://api.github.com/repos/openfisca/openfisca-web-api/languages","stargazers_url":"https://api.github.com/repos/openfisca/openfisca-web-api/stargazers","contributors_url":"https://api.github.com/repos/openfisca/openfisca-web-api/contributors","subscribers_url":"https://api.github.com/repos/openfisca/openfisca-web-api/subscribers","subscription_url":"https://api.github.com/repos/openfisca/openfisca-web-api/subscription","commits_url":"https://api.github.com/repos/openfisca/openfisca-web-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/openfisca/openfisca-web-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/openfisca/openfisca-web-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/openfisca/openfisca-web-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/openfisca/openfisca-web-api/contents/{+path}","compare_url":"https://api.github.com/repos/openfisca/openfisca-web-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openfisca/openfisca-web-api/merges","archive_url":"https://api.github.com/repos/openfisca/openfisca-web-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openfisca/openfisca-web-api/downloads","issues_url":"https://api.github.com/repos/openfisca/openfisca-web-api/issues{/number}","pulls_url":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls{/number}","milestones_url":"https://api.github.com/repos/openfisca/openfisca-web-api/milestones{/number}","notifications_url":"https://api.github.com/repos/openfisca/openfisca-web-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openfisca/openfisca-web-api/labels{/name}","releases_url":"https://api.github.com/repos/openfisca/openfisca-web-api/releases{/id}","created_at":"2013-12-29T15:25:14Z","updated_at":"2015-04-02T14:08:37Z","pushed_at":"2015-04-02T16:07:35Z","git_url":"git://github.com/openfisca/openfisca-web-api.git","ssh_url":"git@github.com:openfisca/openfisca-web-api.git","clone_url":"https://github.com/openfisca/openfisca-web-api.git","svn_url":"https://github.com/openfisca/openfisca-web-api","homepage":null,"size":1263,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/24"},"html":{"href":"https://github.com/openfisca/openfisca-web-api/pull/24"},"issue":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/issues/24"},"comments":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/openfisca/openfisca-web-api/statuses/e004f29bb8854cca1caee6e71b1c41b594f91ca5"}}}}