-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nimbus v1.0 #112
Draft
mfekadu
wants to merge
383
commits into
master
Choose a base branch
from
dev
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Nimbus v1.0 #112
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e.g: invoke docker invoke docker_shell
tested locally with `invoke docker -u my_username` I'm not sure if username is needed tbh.... but if you want to `docker push` then i think you must include your docker username
➜ api git:(mf-patch-and-test) ✗ pytest ============================================= test session starts ============================================= platform darwin -- Python 3.6.8, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 rootdir: /Users/mfekadu/GitHub/api plugins: pylint-0.15.0 collected 1 item tests/test_new_data_courses_endpoint.py F [100%] ================================================== FAILURES =================================================== ____________________________________________ test_post_one_course _____________________________________________ def test_post_one_course(): data = { "courses": [ { "dept": "CPE", "courseNum": 357, "units": "4", "termsOffered": "F,W,SP", "courseName": "Systems Programming", "raw_concurrent_text": "N/A", "raw_recommended_text": "N/A", "raw_prerequisites_text": "CSC/CPE,102,and,CSC/CPE,103", } ] } # aka 'request body' aka 'payload' request_json = json.dumps(data) headers = {"Content-Type": "application/json"} print("request_json:\n\n", request_json, "\n") response = requests.post(URL, data=request_json, headers=headers) # printouts print("response.ok", response.ok) print("response.status_code", response.status_code) print("response.text", response.text) # assertions > assert response.ok is True E assert False is True E + where False = <Response [500]>.ok tests/test_new_data_courses_endpoint.py:37: AssertionError -------------------------------------------- Captured stdout call --------------------------------------------- request_json: {"courses": [{"dept": "CPE", "courseNum": 357, "units": "4", "termsOffered": "F,W,SP", "courseName": "Systems Programming", "raw_concurrent_text": "N/A", "raw_recommended_text": "N/A", "raw_prerequisites_text": "CSC/CPE,102,and,CSC/CPE,103"}]} response.ok False response.status_code 500 response.text <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>TypeError: the JSON object must be str, bytes or bytearray, not 'dict' // Werkzeug Debugger</title> <link rel="stylesheet" href="?__debugger__=yes&cmd=resource&f=style.css" type="text/css"> <!-- We need to make sure this has a favicon so that the debugger does not by accident trigger a request to /favicon.ico which might change the application state. --> <link rel="shortcut icon" href="?__debugger__=yes&cmd=resource&f=console.png"> <script src="?__debugger__=yes&cmd=resource&f=jquery.js"></script> <script src="?__debugger__=yes&cmd=resource&f=debugger.js"></script> <script type="text/javascript"> var TRACEBACK = 4529201616, CONSOLE_MODE = false, EVALEX = true, EVALEX_TRUSTED = false, SECRET = "Bh2NGSwFUQJA1fypQ5oQ"; </script> </head> <body style="background-color: #fff"> <div class="debugger"> <h1>TypeError</h1> <div class="detail"> <p class="errormsg">TypeError: the JSON object must be str, bytes or bytearray, not 'dict'</p> </div> <h2 class="traceback">Traceback <em>(most recent call last)</em></h2> <div class="traceback"> <ul><li><div class="frame" id="frame-4529201728"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">2463</em>, in <code class="function">__call__</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def __call__(self, environ, start_response):</pre> <pre class="line before"><span class="ws"> </span>"""The WSGI server calls the Flask application object as the</pre> <pre class="line before"><span class="ws"> </span>WSGI application. This calls :meth:`wsgi_app` which can be</pre> <pre class="line before"><span class="ws"> </span>wrapped to applying middleware."""</pre> <pre class="line current"><span class="ws"> </span>return self.wsgi_app(environ, start_response)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def __repr__(self):</pre> <pre class="line after"><span class="ws"> </span>return "<%s %r>" % (self.__class__.__name__, self.name)</pre></div> </div> <li><div class="frame" id="frame-4529202288"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">2449</em>, in <code class="function">wsgi_app</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>ctx.push()</pre> <pre class="line before"><span class="ws"> </span>response = self.full_dispatch_request()</pre> <pre class="line before"><span class="ws"> </span>except Exception as e:</pre> <pre class="line before"><span class="ws"> </span>error = e</pre> <pre class="line current"><span class="ws"> </span>response = self.handle_exception(e)</pre> <pre class="line after"><span class="ws"> </span>except: # noqa: B001</pre> <pre class="line after"><span class="ws"> </span>error = sys.exc_info()[1]</pre> <pre class="line after"><span class="ws"> </span>raise</pre> <pre class="line after"><span class="ws"> </span>return response(environ, start_response)</pre> <pre class="line after"><span class="ws"> </span>finally:</pre></div> </div> <li><div class="frame" id="frame-4529202344"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py"</cite>, line <em class="line">161</em>, in <code class="function">wrapped_function</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># Wrap exception handlers with cross_origin</pre> <pre class="line before"><span class="ws"> </span># These error handlers will still respect the behavior of the route</pre> <pre class="line before"><span class="ws"> </span>if options.get('intercept_exceptions', True):</pre> <pre class="line before"><span class="ws"> </span>def _after_request_decorator(f):</pre> <pre class="line before"><span class="ws"> </span>def wrapped_function(*args, **kwargs):</pre> <pre class="line current"><span class="ws"> </span>return cors_after_request(app.make_response(f(*args, **kwargs)))</pre> <pre class="line after"><span class="ws"> </span>return wrapped_function</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if hasattr(app, 'handle_exception'):</pre> <pre class="line after"><span class="ws"> </span>app.handle_exception = _after_request_decorator(</pre> <pre class="line after"><span class="ws"> </span>app.handle_exception)</pre></div> </div> <li><div class="frame" id="frame-4529202064"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1866</em>, in <code class="function">handle_exception</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># if we want to repropagate the exception, we can attempt to</pre> <pre class="line before"><span class="ws"> </span># raise it with the whole traceback in case we can do that</pre> <pre class="line before"><span class="ws"> </span># (the function was actually called from the except part)</pre> <pre class="line before"><span class="ws"> </span># otherwise, we just raise the error again</pre> <pre class="line before"><span class="ws"> </span>if exc_value is e:</pre> <pre class="line current"><span class="ws"> </span>reraise(exc_type, exc_value, tb)</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>raise e</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>self.log_exception((exc_type, exc_value, tb))</pre> <pre class="line after"><span class="ws"> </span>server_error = InternalServerError()</pre></div> </div> <li><div class="frame" id="frame-4529202456"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py"</cite>, line <em class="line">39</em>, in <code class="function">reraise</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>import collections.abc as collections_abc</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def reraise(tp, value, tb=None):</pre> <pre class="line before"><span class="ws"> </span>if value.__traceback__ is not tb:</pre> <pre class="line before"><span class="ws"> </span>raise value.with_traceback(tb)</pre> <pre class="line current"><span class="ws"> </span>raise value</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>implements_to_string = _identity</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span>else:</pre> <pre class="line after"><span class="ws"> </span>iterkeys = lambda d: d.iterkeys()</pre></div> </div> <li><div class="frame" id="frame-4529202120"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">2446</em>, in <code class="function">wsgi_app</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>ctx = self.request_context(environ)</pre> <pre class="line before"><span class="ws"> </span>error = None</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>ctx.push()</pre> <pre class="line current"><span class="ws"> </span>response = self.full_dispatch_request()</pre> <pre class="line after"><span class="ws"> </span>except Exception as e:</pre> <pre class="line after"><span class="ws"> </span>error = e</pre> <pre class="line after"><span class="ws"> </span>response = self.handle_exception(e)</pre> <pre class="line after"><span class="ws"> </span>except: # noqa: B001</pre> <pre class="line after"><span class="ws"> </span>error = sys.exc_info()[1]</pre></div> </div> <li><div class="frame" id="frame-4529202568"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1951</em>, in <code class="function">full_dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>request_started.send(self)</pre> <pre class="line before"><span class="ws"> </span>rv = self.preprocess_request()</pre> <pre class="line before"><span class="ws"> </span>if rv is None:</pre> <pre class="line before"><span class="ws"> </span>rv = self.dispatch_request()</pre> <pre class="line before"><span class="ws"> </span>except Exception as e:</pre> <pre class="line current"><span class="ws"> </span>rv = self.handle_user_exception(e)</pre> <pre class="line after"><span class="ws"> </span>return self.finalize_request(rv)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def finalize_request(self, rv, from_error_handler=False):</pre> <pre class="line after"><span class="ws"> </span>"""Given the return value from a view function this finalizes</pre> <pre class="line after"><span class="ws"> </span>the request by converting it into a response and invoking the</pre></div> </div> <li><div class="frame" id="frame-4529202624"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py"</cite>, line <em class="line">161</em>, in <code class="function">wrapped_function</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># Wrap exception handlers with cross_origin</pre> <pre class="line before"><span class="ws"> </span># These error handlers will still respect the behavior of the route</pre> <pre class="line before"><span class="ws"> </span>if options.get('intercept_exceptions', True):</pre> <pre class="line before"><span class="ws"> </span>def _after_request_decorator(f):</pre> <pre class="line before"><span class="ws"> </span>def wrapped_function(*args, **kwargs):</pre> <pre class="line current"><span class="ws"> </span>return cors_after_request(app.make_response(f(*args, **kwargs)))</pre> <pre class="line after"><span class="ws"> </span>return wrapped_function</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if hasattr(app, 'handle_exception'):</pre> <pre class="line after"><span class="ws"> </span>app.handle_exception = _after_request_decorator(</pre> <pre class="line after"><span class="ws"> </span>app.handle_exception)</pre></div> </div> <li><div class="frame" id="frame-4529202176"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1820</em>, in <code class="function">handle_user_exception</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>return self.handle_http_exception(e)</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>handler = self._find_error_handler(e)</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>if handler is None:</pre> <pre class="line current"><span class="ws"> </span>reraise(exc_type, exc_value, tb)</pre> <pre class="line after"><span class="ws"> </span>return handler(e)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def handle_exception(self, e):</pre> <pre class="line after"><span class="ws"> </span>"""Handle an exception that did not have an error handler</pre> <pre class="line after"><span class="ws"> </span>associated with it, or that was raised from an error handler.</pre></div> </div> <li><div class="frame" id="frame-4529202736"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py"</cite>, line <em class="line">39</em>, in <code class="function">reraise</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>import collections.abc as collections_abc</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def reraise(tp, value, tb=None):</pre> <pre class="line before"><span class="ws"> </span>if value.__traceback__ is not tb:</pre> <pre class="line before"><span class="ws"> </span>raise value.with_traceback(tb)</pre> <pre class="line current"><span class="ws"> </span>raise value</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>implements_to_string = _identity</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span>else:</pre> <pre class="line after"><span class="ws"> </span>iterkeys = lambda d: d.iterkeys()</pre></div> </div> <li><div class="frame" id="frame-4529202232"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1949</em>, in <code class="function">full_dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>self.try_trigger_before_first_request_functions()</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>request_started.send(self)</pre> <pre class="line before"><span class="ws"> </span>rv = self.preprocess_request()</pre> <pre class="line before"><span class="ws"> </span>if rv is None:</pre> <pre class="line current"><span class="ws"> </span>rv = self.dispatch_request()</pre> <pre class="line after"><span class="ws"> </span>except Exception as e:</pre> <pre class="line after"><span class="ws"> </span>rv = self.handle_user_exception(e)</pre> <pre class="line after"><span class="ws"> </span>return self.finalize_request(rv)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def finalize_request(self, rv, from_error_handler=False):</pre></div> </div> <li><div class="frame" id="frame-4529202848"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1935</em>, in <code class="function">dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>getattr(rule, "provide_automatic_options", False)</pre> <pre class="line before"><span class="ws"> </span>and req.method == "OPTIONS"</pre> <pre class="line before"><span class="ws"> </span>):</pre> <pre class="line before"><span class="ws"> </span>return self.make_default_options_response()</pre> <pre class="line before"><span class="ws"> </span># otherwise dispatch to the handler for that endpoint</pre> <pre class="line current"><span class="ws"> </span>return self.view_functions[rule.endpoint](**req.view_args)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def full_dispatch_request(self):</pre> <pre class="line after"><span class="ws"> </span>"""Dispatches the request and on top of that performs request</pre> <pre class="line after"><span class="ws"> </span>pre and postprocessing as well as HTTP exception catching and</pre> <pre class="line after"><span class="ws"> </span>error handling.</pre></div> </div> <li><div class="frame" id="frame-4529202904"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/flask_api.py"</cite>, line <em class="line">121</em>, in <code class="function">save_courses</code></h4> <div class="source "><pre class="line before"><span class="ws"></span>@app.route('/new_data/courses', methods=['POST'])</pre> <pre class="line before"><span class="ws"></span>def save_courses():</pre> <pre class="line before"><span class="ws"> </span>"""</pre> <pre class="line before"><span class="ws"> </span>Persists list of courses</pre> <pre class="line before"><span class="ws"> </span>"""</pre> <pre class="line current"><span class="ws"> </span>data = json.loads(request.get_json())</pre> <pre class="line after"><span class="ws"> </span>db = NimbusMySQLAlchemy(config_file=CONFIG_FILE_PATH)</pre> <pre class="line after"><span class="ws"> </span>for course in data['courses']:</pre> <pre class="line after"><span class="ws"> </span>try:</pre> <pre class="line after"><span class="ws"> </span>db.save_course(course)</pre> <pre class="line after"><span class="ws"> </span>except BadDictionaryKeyError as e:</pre></div> </div> <li><div class="frame" id="frame-4529201952"> <h4>File <cite class="filename">"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py"</cite>, line <em class="line">348</em>, in <code class="function">loads</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",</pre> <pre class="line before"><span class="ws"> </span>s, 0)</pre> <pre class="line before"><span class="ws"> </span>else:</pre> <pre class="line before"><span class="ws"> </span>if not isinstance(s, (bytes, bytearray)):</pre> <pre class="line before"><span class="ws"> </span>raise TypeError('the JSON object must be str, bytes or bytearray, '</pre> <pre class="line current"><span class="ws"> </span>'not {!r}'.format(s.__class__.__name__))</pre> <pre class="line after"><span class="ws"> </span>s = s.decode(detect_encoding(s), 'surrogatepass')</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if (cls is None and object_hook is None and</pre> <pre class="line after"><span class="ws"> </span>parse_int is None and parse_float is None and</pre> <pre class="line after"><span class="ws"> </span>parse_constant is None and object_pairs_hook is None and not kw):</pre></div> </div> </ul> <blockquote>TypeError: the JSON object must be str, bytes or bytearray, not 'dict'</blockquote> </div> <div class="plain"> <form action="/?__debugger__=yes&cmd=paste" method="post"> <p> <input type="hidden" name="language" value="pytb"> This is the Copy/Paste friendly version of the traceback. <span class="pastemessage">You can also paste this traceback into a <a href="https://gist.github.com/">gist</a>: <input type="submit" value="create paste"></span> </p> <textarea cols="50" rows="10" name="code" readonly>Traceback (most recent call last): File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app response = self.handle_exception(e) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/mfekadu/GitHub/api/flask_api.py", line 121, in save_courses data = json.loads(request.get_json()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 348, in loads 'not {!r}'.format(s.__class__.__name__)) TypeError: the JSON object must be str, bytes or bytearray, not 'dict'</textarea> </form> </div> <div class="explanation"> The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. <span class="nojavascript"> If you enable JavaScript you can also use additional features such as code execution (if the evalex feature is enabled), automatic pasting of the exceptions and much more.</span> </div> <div class="footer"> Brought to you by <strong class="arthur">DON'T PANIC</strong>, your friendly Werkzeug powered traceback interpreter. </div> </div> <div class="pin-prompt"> <div class="inner"> <h3>Console Locked</h3> <p> The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server. <form> <p>PIN: <input type=text name=pin size=14> <input type=submit name=btn value="Confirm Pin"> </form> </div> </div> </body> </html> <!-- Traceback (most recent call last): File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app response = self.handle_exception(e) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/mfekadu/GitHub/api/flask_api.py", line 121, in save_courses data = json.loads(request.get_json()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 348, in loads 'not {!r}'.format(s.__class__.__name__)) TypeError: the JSON object must be str, bytes or bytearray, not 'dict' --> ============================================== 1 failed in 0.42s ============================================== ➜ api git:(mf-patch-and-test) ✗
➜ api git:(mf-patch-and-test) ✗ pytest ============================================= test session starts ============================================= platform darwin -- Python 3.6.8, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 rootdir: /Users/mfekadu/GitHub/api plugins: pylint-0.15.0 collected 1 item tests/test_new_data_courses_endpoint.py . [100%] ============================================== 1 passed in 2.74s ============================================== ➜ api git:(mf-patch-and-test) ✗
<li><div class="frame" id="frame-4592973864"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">2446</em>, in <code class="function">wsgi_app</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>ctx = self.request_context(environ)</pre> <pre class="line before"><span class="ws"> </span>error = None</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>ctx.push()</pre> <pre class="line current"><span class="ws"> </span>response = self.full_dispatch_request()</pre> <pre class="line after"><span class="ws"> </span>except Exception as e:</pre> <pre class="line after"><span class="ws"> </span>error = e</pre> <pre class="line after"><span class="ws"> </span>response = self.handle_exception(e)</pre> <pre class="line after"><span class="ws"> </span>except: # noqa: B001</pre> <pre class="line after"><span class="ws"> </span>error = sys.exc_info()[1]</pre></div> </div> <li><div class="frame" id="frame-4592974312"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1951</em>, in <code class="function">full_dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>request_started.send(self)</pre> <pre class="line before"><span class="ws"> </span>rv = self.preprocess_request()</pre> <pre class="line before"><span class="ws"> </span>if rv is None:</pre> <pre class="line before"><span class="ws"> </span>rv = self.dispatch_request()</pre> <pre class="line before"><span class="ws"> </span>except Exception as e:</pre> <pre class="line current"><span class="ws"> </span>rv = self.handle_user_exception(e)</pre> <pre class="line after"><span class="ws"> </span>return self.finalize_request(rv)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def finalize_request(self, rv, from_error_handler=False):</pre> <pre class="line after"><span class="ws"> </span>"""Given the return value from a view function this finalizes</pre> <pre class="line after"><span class="ws"> </span>the request by converting it into a response and invoking the</pre></div> </div> <li><div class="frame" id="frame-4592974368"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py"</cite>, line <em class="line">161</em>, in <code class="function">wrapped_function</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># Wrap exception handlers with cross_origin</pre> <pre class="line before"><span class="ws"> </span># These error handlers will still respect the behavior of the route</pre> <pre class="line before"><span class="ws"> </span>if options.get('intercept_exceptions', True):</pre> <pre class="line before"><span class="ws"> </span>def _after_request_decorator(f):</pre> <pre class="line before"><span class="ws"> </span>def wrapped_function(*args, **kwargs):</pre> <pre class="line current"><span class="ws"> </span>return cors_after_request(app.make_response(f(*args, **kwargs)))</pre> <pre class="line after"><span class="ws"> </span>return wrapped_function</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if hasattr(app, 'handle_exception'):</pre> <pre class="line after"><span class="ws"> </span>app.handle_exception = _after_request_decorator(</pre> <pre class="line after"><span class="ws"> </span>app.handle_exception)</pre></div> </div> <li><div class="frame" id="frame-4592973920"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1820</em>, in <code class="function">handle_user_exception</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>return self.handle_http_exception(e)</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>handler = self._find_error_handler(e)</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>if handler is None:</pre> <pre class="line current"><span class="ws"> </span>reraise(exc_type, exc_value, tb)</pre> <pre class="line after"><span class="ws"> </span>return handler(e)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def handle_exception(self, e):</pre> <pre class="line after"><span class="ws"> </span>"""Handle an exception that did not have an error handler</pre> <pre class="line after"><span class="ws"> </span>associated with it, or that was raised from an error handler.</pre></div> </div> <li><div class="frame" id="frame-4592974816"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py"</cite>, line <em class="line">39</em>, in <code class="function">reraise</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>import collections.abc as collections_abc</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def reraise(tp, value, tb=None):</pre> <pre class="line before"><span class="ws"> </span>if value.__traceback__ is not tb:</pre> <pre class="line before"><span class="ws"> </span>raise value.with_traceback(tb)</pre> <pre class="line current"><span class="ws"> </span>raise value</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>implements_to_string = _identity</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span>else:</pre> <pre class="line after"><span class="ws"> </span>iterkeys = lambda d: d.iterkeys()</pre></div> </div> <li><div class="frame" id="frame-4592973976"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1949</em>, in <code class="function">full_dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>self.try_trigger_before_first_request_functions()</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>request_started.send(self)</pre> <pre class="line before"><span class="ws"> </span>rv = self.preprocess_request()</pre> <pre class="line before"><span class="ws"> </span>if rv is None:</pre> <pre class="line current"><span class="ws"> </span>rv = self.dispatch_request()</pre> <pre class="line after"><span class="ws"> </span>except Exception as e:</pre> <pre class="line after"><span class="ws"> </span>rv = self.handle_user_exception(e)</pre> <pre class="line after"><span class="ws"> </span>return self.finalize_request(rv)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def finalize_request(self, rv, from_error_handler=False):</pre></div> </div> <li><div class="frame" id="frame-4592974928"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py"</cite>, line <em class="line">1935</em>, in <code class="function">dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>getattr(rule, "provide_automatic_options", False)</pre> <pre class="line before"><span class="ws"> </span>and req.method == "OPTIONS"</pre> <pre class="line before"><span class="ws"> </span>):</pre> <pre class="line before"><span class="ws"> </span>return self.make_default_options_response()</pre> <pre class="line before"><span class="ws"> </span># otherwise dispatch to the handler for that endpoint</pre> <pre class="line current"><span class="ws"> </span>return self.view_functions[rule.endpoint](**req.view_args)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def full_dispatch_request(self):</pre> <pre class="line after"><span class="ws"> </span>"""Dispatches the request and on top of that performs request</pre> <pre class="line after"><span class="ws"> </span>pre and postprocessing as well as HTTP exception catching and</pre> <pre class="line after"><span class="ws"> </span>error handling.</pre></div> </div> <li><div class="frame" id="frame-4592974984"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/flask_api.py"</cite>, line <em class="line">161</em>, in <code class="function">save_clubs</code></h4> <div class="source "><pre class="line before"><span class="ws"> </span>return str(e), BAD_REQUEST</pre> <pre class="line before"><span class="ws"> </span>except Exception as e:</pre> <pre class="line before"><span class="ws"> </span># TODO: consider security tradeoff of displaying internal server errors</pre> <pre class="line before"><span class="ws"> </span># versus development time (being able to see errors quickly)</pre> <pre class="line before"><span class="ws"> </span># HINT: security always wins</pre> <pre class="line current"><span class="ws"> </span>raise e</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>return "SUCCESS"</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span>@app.route('/new_data/locations', methods=['POST'])</pre></div> </div> <li><div class="frame" id="frame-4592973752"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/flask_api.py"</cite>, line <em class="line">150</em>, in <code class="function">save_clubs</code></h4> <div class="source "><pre class="line before"><span class="ws"> </span>"""</pre> <pre class="line before"><span class="ws"> </span>data = request.get_json()</pre> <pre class="line before"><span class="ws"> </span>db = NimbusMySQLAlchemy(config_file=CONFIG_FILE_PATH)</pre> <pre class="line before"><span class="ws"> </span>for club in data['clubs']:</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line current"><span class="ws"> </span>db.save_club(club)</pre> <pre class="line after"><span class="ws"> </span>except BadDictionaryKeyError as e:</pre> <pre class="line after"><span class="ws"> </span>return str(e), BAD_REQUEST</pre> <pre class="line after"><span class="ws"> </span>except BadDictionaryValueError as e:</pre> <pre class="line after"><span class="ws"> </span>return str(e), BAD_REQUEST</pre> <pre class="line after"><span class="ws"> </span>except NimbusDatabaseError as e:</pre></div> </div> <li><div class="frame" id="frame-4592973584"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/database_wrapper.py"</cite>, line <em class="line">581</em>, in <code class="function">save_club</code></h4> <div class="source "><pre class="line before"><span class="ws"> </span>club_data.box = formatted_data['box']</pre> <pre class="line before"><span class="ws"> </span>club_data.advisor = formatted_data['advisor']</pre> <pre class="line before"><span class="ws"> </span>club_data.affiliation = formatted_data['affiliation']</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>self.session.add(club_data)</pre> <pre class="line current"><span class="ws"> </span>self.session.commit()</pre> <pre class="line after"><span class="ws"> </span>return True</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>@raises_database_error # noqa - C901 "too complex" - agreed TODO: reduce complexity</pre> <pre class="line after"><span class="ws"> </span>def save_audio_sample_meta_data(self, formatted_data: dict) -> bool:</pre> <pre class="line after"><span class="ws"> </span>"""</pre></div> </div> <li><div class="frame" id="frame-4592973696"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">1036</em>, in <code class="function">commit</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>if not self.autocommit:</pre> <pre class="line before"><span class="ws"> </span>self.begin()</pre> <pre class="line before"><span class="ws"> </span>else:</pre> <pre class="line before"><span class="ws"> </span>raise sa_exc.InvalidRequestError("No transaction is begun.")</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line current"><span class="ws"> </span>self.transaction.commit()</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def prepare(self):</pre> <pre class="line after"><span class="ws"> </span>"""Prepare the current transaction in progress for two phase commit.</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>If no transaction is in progress, this method raises an</pre></div> </div> <li><div class="frame" id="frame-4592974144"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">503</em>, in <code class="function">commit</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>self._state = PREPARED</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def commit(self):</pre> <pre class="line before"><span class="ws"> </span>self._assert_active(prepared_ok=True)</pre> <pre class="line before"><span class="ws"> </span>if self._state is not PREPARED:</pre> <pre class="line current"><span class="ws"> </span>self._prepare_impl()</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if self._parent is None or self.nested:</pre> <pre class="line after"><span class="ws"> </span>for t in set(self._connections.values()):</pre> <pre class="line after"><span class="ws"> </span>t[1].commit()</pre> <pre class="line after"><span class="ws"></span> </pre></div> </div> <li><div class="frame" id="frame-4592974256"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">482</em>, in <code class="function">_prepare_impl</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>if not self.session._flushing:</pre> <pre class="line before"><span class="ws"> </span>for _flush_guard in range(100):</pre> <pre class="line before"><span class="ws"> </span>if self.session._is_clean():</pre> <pre class="line before"><span class="ws"> </span>break</pre> <pre class="line current"><span class="ws"> </span>self.session.flush()</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>raise exc.FlushError(</pre> <pre class="line after"><span class="ws"> </span>"Over 100 subsequent flushes have occurred within "</pre> <pre class="line after"><span class="ws"> </span>"session.commit() - is an after_flush() hook "</pre> <pre class="line after"><span class="ws"> </span>"creating new objects?"</pre></div> </div> <li><div class="frame" id="frame-4592974424"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">2479</em>, in <code class="function">flush</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>if self._is_clean():</pre> <pre class="line before"><span class="ws"> </span>return</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>self._flushing = True</pre> <pre class="line current"><span class="ws"> </span>self._flush(objects)</pre> <pre class="line after"><span class="ws"> </span>finally:</pre> <pre class="line after"><span class="ws"> </span>self._flushing = False</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def _flush_warning(self, method):</pre> <pre class="line after"><span class="ws"> </span>util.warn(</pre></div> </div> <li><div class="frame" id="frame-4592974872"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">2617</em>, in <code class="function">_flush</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>transaction.commit()</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>except:</pre> <pre class="line before"><span class="ws"> </span>with util.safe_reraise():</pre> <pre class="line current"><span class="ws"> </span>transaction.rollback(_capture_exception=True)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def bulk_save_objects(</pre> <pre class="line after"><span class="ws"> </span>self,</pre> <pre class="line after"><span class="ws"> </span>objects,</pre> <pre class="line after"><span class="ws"> </span>return_defaults=False,</pre></div> </div> <li><div class="frame" id="frame-4592975040"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py"</cite>, line <em class="line">68</em>, in <code class="function">__exit__</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># see #2703 for notes</pre> <pre class="line before"><span class="ws"> </span>if type_ is None:</pre> <pre class="line before"><span class="ws"> </span>exc_type, exc_value, exc_tb = self._exc_info</pre> <pre class="line before"><span class="ws"> </span>self._exc_info = None # remove potential circular references</pre> <pre class="line before"><span class="ws"> </span>if not self.warn_only:</pre> <pre class="line current"><span class="ws"> </span>compat.reraise(exc_type, exc_value, exc_tb)</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>if not compat.py3k and self._exc_info and self._exc_info[1]:</pre> <pre class="line after"><span class="ws"> </span># emulate Py3K's behavior of telling us when an exception</pre> <pre class="line after"><span class="ws"> </span># occurs in an exception handler.</pre> <pre class="line after"><span class="ws"> </span>warn(</pre></div> </div> <li><div class="frame" id="frame-4592975096"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py"</cite>, line <em class="line">153</em>, in <code class="function">reraise</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>if cause is not None:</pre> <pre class="line before"><span class="ws"> </span>assert cause is not value, "Same cause emitted"</pre> <pre class="line before"><span class="ws"> </span>value.__cause__ = cause</pre> <pre class="line before"><span class="ws"> </span>if value.__traceback__ is not tb:</pre> <pre class="line before"><span class="ws"> </span>raise value.with_traceback(tb)</pre> <pre class="line current"><span class="ws"> </span>raise value</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def u(s):</pre> <pre class="line after"><span class="ws"> </span>return s</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def ue(s):</pre></div> </div> <li><div class="frame" id="frame-4592975152"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">2577</em>, in <code class="function">_flush</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>subtransactions=True</pre> <pre class="line before"><span class="ws"> </span>)</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>self._warn_on_events = True</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line current"><span class="ws"> </span>flush_context.execute()</pre> <pre class="line after"><span class="ws"> </span>finally:</pre> <pre class="line after"><span class="ws"> </span>self._warn_on_events = False</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>self.dispatch.after_flush(self, flush_context)</pre> <pre class="line after"><span class="ws"></span> </pre></div> </div> <li><div class="frame" id="frame-4592975208"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py"</cite>, line <em class="line">422</em>, in <code class="function">execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>while set_:</pre> <pre class="line before"><span class="ws"> </span>n = set_.pop()</pre> <pre class="line before"><span class="ws"> </span>n.execute_aggregate(self, set_)</pre> <pre class="line before"><span class="ws"> </span>else:</pre> <pre class="line before"><span class="ws"> </span>for rec in topological.sort(self.dependencies, postsort_actions):</pre> <pre class="line current"><span class="ws"> </span>rec.execute(self)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def finalize_flush_changes(self):</pre> <pre class="line after"><span class="ws"> </span>"""mark processed objects as clean / deleted after a successful</pre> <pre class="line after"><span class="ws"> </span>flush().</pre> <pre class="line after"><span class="ws"></span> </pre></div> </div> <li><div class="frame" id="frame-4592975264"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py"</cite>, line <em class="line">589</em>, in <code class="function">execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def execute(self, uow):</pre> <pre class="line before"><span class="ws"> </span>persistence.save_obj(</pre> <pre class="line before"><span class="ws"> </span>self.mapper,</pre> <pre class="line before"><span class="ws"> </span>uow.states_for_mapper_hierarchy(self.mapper, False, False),</pre> <pre class="line current"><span class="ws"> </span>uow,</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def per_state_flush_actions(self, uow):</pre> <pre class="line after"><span class="ws"> </span>states = list(</pre> <pre class="line after"><span class="ws"> </span>uow.states_for_mapper_hierarchy(self.mapper, False, False)</pre></div> </div> <li><div class="frame" id="frame-4592975320"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py"</cite>, line <em class="line">245</em>, in <code class="function">save_obj</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>base_mapper,</pre> <pre class="line before"><span class="ws"> </span>uowtransaction,</pre> <pre class="line before"><span class="ws"> </span>cached_connections,</pre> <pre class="line before"><span class="ws"> </span>mapper,</pre> <pre class="line before"><span class="ws"> </span>table,</pre> <pre class="line current"><span class="ws"> </span>insert,</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>_finalize_insert_update_commands(</pre> <pre class="line after"><span class="ws"> </span>base_mapper,</pre> <pre class="line after"><span class="ws"> </span>uowtransaction,</pre></div> </div> <li><div class="frame" id="frame-4592975376"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py"</cite>, line <em class="line">1137</em>, in <code class="function">_emit_insert_statements</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>result = connection.execute(</pre> <pre class="line before"><span class="ws"> </span>statement.values(value_params), params</pre> <pre class="line before"><span class="ws"> </span>)</pre> <pre class="line before"><span class="ws"> </span>else:</pre> <pre class="line before"><span class="ws"> </span>result = cached_connections[connection].execute(</pre> <pre class="line current"><span class="ws"> </span>statement, params</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>primary_key = result.context.inserted_primary_key</pre> <pre class="line after"><span class="ws"> </span>if primary_key is not None:</pre> <pre class="line after"><span class="ws"> </span># set primary key attributes</pre></div> </div> <li><div class="frame" id="frame-4592975432"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">982</em>, in <code class="function">execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>meth = object_._execute_on_connection</pre> <pre class="line before"><span class="ws"> </span>except AttributeError:</pre> <pre class="line before"><span class="ws"> </span>raise exc.ObjectNotExecutableError(object_)</pre> <pre class="line before"><span class="ws"> </span>else:</pre> <pre class="line current"><span class="ws"> </span>return meth(self, multiparams, params)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def _execute_function(self, func, multiparams, params):</pre> <pre class="line after"><span class="ws"> </span>"""Execute a sql.FunctionElement object."""</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>return self._execute_clauseelement(func.select(), multiparams, params)</pre></div> </div> <li><div class="frame" id="frame-4592975656"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/sql/elements.py"</cite>, line <em class="line">293</em>, in <code class="function">_execute_on_connection</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># self</pre> <pre class="line before"><span class="ws"> </span>return self</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def _execute_on_connection(self, connection, multiparams, params):</pre> <pre class="line before"><span class="ws"> </span>if self.supports_execution:</pre> <pre class="line current"><span class="ws"> </span>return connection._execute_clauseelement(self, multiparams, params)</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>raise exc.ObjectNotExecutableError(self)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def unique_params(self, *optionaldict, **kwargs):</pre> <pre class="line after"><span class="ws"> </span>"""Return a copy with :func:`bindparam()` elements replaced.</pre></div> </div> <li><div class="frame" id="frame-4592975488"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1101</em>, in <code class="function">_execute_clauseelement</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>dialect,</pre> <pre class="line before"><span class="ws"> </span>dialect.execution_ctx_cls._init_compiled,</pre> <pre class="line before"><span class="ws"> </span>compiled_sql,</pre> <pre class="line before"><span class="ws"> </span>distilled_params,</pre> <pre class="line before"><span class="ws"> </span>compiled_sql,</pre> <pre class="line current"><span class="ws"> </span>distilled_params,</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"> </span>if self._has_events or self.engine._has_events:</pre> <pre class="line after"><span class="ws"> </span>self.dispatch.after_execute(self, elem, multiparams, params, ret)</pre> <pre class="line after"><span class="ws"> </span>return ret</pre> <pre class="line after"><span class="ws"></span> </pre></div> </div> <li><div class="frame" id="frame-4592975768"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1250</em>, in <code class="function">_execute_context</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>self.dialect.do_execute(</pre> <pre class="line before"><span class="ws"> </span>cursor, statement, parameters, context</pre> <pre class="line before"><span class="ws"> </span>)</pre> <pre class="line before"><span class="ws"> </span>except BaseException as e:</pre> <pre class="line before"><span class="ws"> </span>self._handle_dbapi_exception(</pre> <pre class="line current"><span class="ws"> </span>e, statement, parameters, cursor, context</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if self._has_events or self.engine._has_events:</pre> <pre class="line after"><span class="ws"> </span>self.dispatch.after_cursor_execute(</pre> <pre class="line after"><span class="ws"> </span>self,</pre></div> </div> <li><div class="frame" id="frame-4592975824"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1476</em>, in <code class="function">_handle_dbapi_exception</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>self._autorollback()</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>if newraise:</pre> <pre class="line before"><span class="ws"> </span>util.raise_from_cause(newraise, exc_info)</pre> <pre class="line before"><span class="ws"> </span>elif should_wrap:</pre> <pre class="line current"><span class="ws"> </span>util.raise_from_cause(sqlalchemy_exception, exc_info)</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>util.reraise(*exc_info)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>finally:</pre> <pre class="line after"><span class="ws"> </span>del self._reentrant_error</pre></div> </div> <li><div class="frame" id="frame-4592975712"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py"</cite>, line <em class="line">398</em>, in <code class="function">raise_from_cause</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span>def raise_from_cause(exception, exc_info=None):</pre> <pre class="line before"><span class="ws"> </span>if exc_info is None:</pre> <pre class="line before"><span class="ws"> </span>exc_info = sys.exc_info()</pre> <pre class="line before"><span class="ws"> </span>exc_type, exc_value, exc_tb = exc_info</pre> <pre class="line before"><span class="ws"> </span>cause = exc_value if exc_value is not exception else None</pre> <pre class="line current"><span class="ws"> </span>reraise(type(exception), exception, tb=exc_tb, cause=cause)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span>def with_metaclass(meta, *bases):</pre> <pre class="line after"><span class="ws"> </span>"""Create a base class with a metaclass.</pre> <pre class="line after"><span class="ws"></span> </pre></div> </div> <li><div class="frame" id="frame-4592975600"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py"</cite>, line <em class="line">152</em>, in <code class="function">reraise</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>def reraise(tp, value, tb=None, cause=None):</pre> <pre class="line before"><span class="ws"> </span>if cause is not None:</pre> <pre class="line before"><span class="ws"> </span>assert cause is not value, "Same cause emitted"</pre> <pre class="line before"><span class="ws"> </span>value.__cause__ = cause</pre> <pre class="line before"><span class="ws"> </span>if value.__traceback__ is not tb:</pre> <pre class="line current"><span class="ws"> </span>raise value.with_traceback(tb)</pre> <pre class="line after"><span class="ws"> </span>raise value</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def u(s):</pre> <pre class="line after"><span class="ws"> </span>return s</pre> <pre class="line after"><span class="ws"></span> </pre></div> </div> <li><div class="frame" id="frame-4592975544"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1246</em>, in <code class="function">_execute_context</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>if fn(cursor, statement, parameters, context):</pre> <pre class="line before"><span class="ws"> </span>evt_handled = True</pre> <pre class="line before"><span class="ws"> </span>break</pre> <pre class="line before"><span class="ws"> </span>if not evt_handled:</pre> <pre class="line before"><span class="ws"> </span>self.dialect.do_execute(</pre> <pre class="line current"><span class="ws"> </span>cursor, statement, parameters, context</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"> </span>except BaseException as e:</pre> <pre class="line after"><span class="ws"> </span>self._handle_dbapi_exception(</pre> <pre class="line after"><span class="ws"> </span>e, statement, parameters, cursor, context</pre> <pre class="line after"><span class="ws"> </span>)</pre></div> </div> <li><div class="frame" id="frame-4593058256"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py"</cite>, line <em class="line">588</em>, in <code class="function">do_execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def do_executemany(self, cursor, statement, parameters, context=None):</pre> <pre class="line before"><span class="ws"> </span>cursor.executemany(statement, parameters)</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def do_execute(self, cursor, statement, parameters, context=None):</pre> <pre class="line current"><span class="ws"> </span>cursor.execute(statement, parameters)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def do_execute_no_params(self, cursor, statement, context=None):</pre> <pre class="line after"><span class="ws"> </span>cursor.execute(statement)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def is_disconnect(self, e, connection, cursor):</pre></div> </div> <li><div class="frame" id="frame-4593058088"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/cursor_cext.py"</cite>, line <em class="line">266</em>, in <code class="function">execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>"Not all parameters were used in the SQL statement")</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>result = self._cnx.cmd_query(stmt, raw=self._raw,</pre> <pre class="line before"><span class="ws"> </span>buffered=self._buffered,</pre> <pre class="line current"><span class="ws"> </span>raw_as_string=self._raw_as_string)</pre> <pre class="line after"><span class="ws"> </span>except MySQLInterfaceError as exc:</pre> <pre class="line after"><span class="ws"> </span>raise errors.get_mysql_exception(msg=exc.msg, errno=exc.errno,</pre> <pre class="line after"><span class="ws"> </span>sqlstate=exc.sqlstate)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>self._executed = stmt</pre></div> </div> <li><div class="frame" id="frame-4593057920"> <h4>File <cite class="filename">"/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/connection_cext.py"</cite>, line <em class="line">475</em>, in <code class="function">cmd_query</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>self._cmysql.query(query,</pre> <pre class="line before"><span class="ws"> </span>raw=raw, buffered=buffered,</pre> <pre class="line before"><span class="ws"> </span>raw_as_string=raw_as_string)</pre> <pre class="line before"><span class="ws"> </span>except MySQLInterfaceError as exc:</pre> <pre class="line before"><span class="ws"> </span>raise errors.get_mysql_exception(exc.errno, msg=exc.msg,</pre> <pre class="line current"><span class="ws"> </span>sqlstate=exc.sqlstate)</pre> <pre class="line after"><span class="ws"> </span>except AttributeError:</pre> <pre class="line after"><span class="ws"> </span>if self._unix_socket:</pre> <pre class="line after"><span class="ws"> </span>addr = self._unix_socket</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>addr = self._host + ':' + str(self._port)</pre></div> </div> </ul> <blockquote>sqlalchemy.exc.DataError: (mysql.connector.errors.DataError) 1406 (22001): Data too long for column 'contact_phone' at row 1 [SQL: INSERT INTO `Clubs` (club_name, types, `desc`, contact_email, contact_email_2, contact_person, contact_phone, box, advisor, affiliation) VALUES (%(club_name)s, %(types)s, %(desc)s, %(contact_email)s, %(contact_email_2)s, %(contact_person)s, %(contact_phone)s, %(box)s, %(advisor)s, %(affiliation)s)] [parameters: {'club_name': 'test_club', 'types': 'Academic, Special Interest', 'desc': 'description', 'contact_email': '[email protected]', 'contact_email_2': '[email protected]', 'contact_person': 'Test Person', 'contact_phone': 15552223232, 'box': 89, 'advisor': 'Test Person', 'affiliation': None}] (Background on this error at: http://sqlalche.me/e/9h9h)</blockquote> </div> <div class="plain"> <form action="/?__debugger__=yes&cmd=paste" method="post"> <p> <input type="hidden" name="language" value="pytb"> This is the Copy/Paste friendly version of the traceback. <span class="pastemessage">You can also paste this traceback into a <a href="https://gist.github.com/">gist</a>: <input type="submit" value="create paste"></span> </p> <textarea cols="50" rows="10" name="code" readonly>Traceback (most recent call last): File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/connection_cext.py", line 472, in cmd_query raw_as_string=raw_as_string) _mysql_connector.MySQLInterfaceError: Data too long for column 'contact_phone' at row 1 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1246, in _execute_context cursor, statement, parameters, context File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute cursor.execute(statement, parameters) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/cursor_cext.py", line 266, in execute raw_as_string=self._raw_as_string) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/connection_cext.py", line 475, in cmd_query sqlstate=exc.sqlstate) mysql.connector.errors.DataError: 1406 (22001): Data too long for column 'contact_phone' at row 1 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app response = self.handle_exception(e) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/mfekadu/GitHub/api/flask_api.py", line 161, in save_clubs raise e File "/Users/mfekadu/GitHub/api/flask_api.py", line 150, in save_clubs db.save_club(club) File "/Users/mfekadu/GitHub/api/database_wrapper.py", line 581, in save_club self.session.commit() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1036, in commit self.transaction.commit() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 503, in commit self._prepare_impl() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 482, in _prepare_impl self.session.flush() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2479, in flush self._flush(objects) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2617, in _flush transaction.rollback(_capture_exception=True) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__ compat.reraise(exc_type, exc_value, exc_tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 153, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2577, in _flush flush_context.execute() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute rec.execute(self) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute uow, File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj insert, File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 1137, in _emit_insert_statements statement, params File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 982, in execute return meth(self, multiparams, params) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 293, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1101, in _execute_clauseelement distilled_params, File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1250, in _execute_context e, statement, parameters, cursor, context File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception util.raise_from_cause(sqlalchemy_exception, exc_info) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 152, in reraise raise value.with_traceback(tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1246, in _execute_context cursor, statement, parameters, context File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute cursor.execute(statement, parameters) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/cursor_cext.py", line 266, in execute raw_as_string=self._raw_as_string) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/connection_cext.py", line 475, in cmd_query sqlstate=exc.sqlstate) sqlalchemy.exc.DataError: (mysql.connector.errors.DataError) 1406 (22001): Data too long for column 'contact_phone' at row 1 [SQL: INSERT INTO `Clubs` (club_name, types, `desc`, contact_email, contact_email_2, contact_person, contact_phone, box, advisor, affiliation) VALUES (%(club_name)s, %(types)s, %(desc)s, %(contact_email)s, %(contact_email_2)s, %(contact_person)s, %(contact_phone)s, %(box)s, %(advisor)s, %(affiliation)s)] [parameters: {'club_name': 'test_club', 'types': 'Academic, Special Interest', 'desc': 'description', 'contact_email': '[email protected]', 'contact_email_2': '[email protected]', 'contact_person': 'Test Person', 'contact_phone': 15552223232, 'box': 89, 'advisor': 'Test Person', 'affiliation': None}] (Background on this error at: http://sqlalche.me/e/9h9h)</textarea> </form> </div> <div class="explanation"> The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. <span class="nojavascript"> If you enable JavaScript you can also use additional features such as code execution (if the evalex feature is enabled), automatic pasting of the exceptions and much more.</span> </div> <div class="footer"> Brought to you by <strong class="arthur">DON'T PANIC</strong>, your friendly Werkzeug powered traceback interpreter. </div> </div> <div class="pin-prompt"> <div class="inner"> <h3>Console Locked</h3> <p> The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server. <form> <p>PIN: <input type=text name=pin size=14> <input type=submit name=btn value="Confirm Pin"> </form> </div> </div> </body> </html> <!-- Traceback (most recent call last): File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/connection_cext.py", line 472, in cmd_query raw_as_string=raw_as_string) _mysql_connector.MySQLInterfaceError: Data too long for column 'contact_phone' at row 1 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1246, in _execute_context cursor, statement, parameters, context File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute cursor.execute(statement, parameters) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/cursor_cext.py", line 266, in execute raw_as_string=self._raw_as_string) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/connection_cext.py", line 475, in cmd_query sqlstate=exc.sqlstate) mysql.connector.errors.DataError: 1406 (22001): Data too long for column 'contact_phone' at row 1 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app response = self.handle_exception(e) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception reraise(exc_type, exc_value, tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/mfekadu/GitHub/api/flask_api.py", line 161, in save_clubs raise e File "/Users/mfekadu/GitHub/api/flask_api.py", line 150, in save_clubs db.save_club(club) File "/Users/mfekadu/GitHub/api/database_wrapper.py", line 581, in save_club self.session.commit() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1036, in commit self.transaction.commit() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 503, in commit self._prepare_impl() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 482, in _prepare_impl self.session.flush() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2479, in flush self._flush(objects) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2617, in _flush transaction.rollback(_capture_exception=True) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__ compat.reraise(exc_type, exc_value, exc_tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 153, in reraise raise value File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2577, in _flush flush_context.execute() File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute rec.execute(self) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute uow, File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj insert, File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 1137, in _emit_insert_statements statement, params File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 982, in execute return meth(self, multiparams, params) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 293, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1101, in _execute_clauseelement distilled_params, File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1250, in _execute_context e, statement, parameters, cursor, context File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception util.raise_from_cause(sqlalchemy_exception, exc_info) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 152, in reraise raise value.with_traceback(tb) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1246, in _execute_context cursor, statement, parameters, context File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute cursor.execute(statement, parameters) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/cursor_cext.py", line 266, in execute raw_as_string=self._raw_as_string) File "/Users/mfekadu/GitHub/api/venv/lib/python3.6/site-packages/mysql/connector/connection_cext.py", line 475, in cmd_query sqlstate=exc.sqlstate) sqlalchemy.exc.DataError: (mysql.connector.errors.DataError) 1406 (22001): Data too long for column 'contact_phone' at row 1 [SQL: INSERT INTO `Clubs` (club_name, types, `desc`, contact_email, contact_email_2, contact_person, contact_phone, box, advisor, affiliation) VALUES (%(club_name)s, %(types)s, %(desc)s, %(contact_email)s, %(contact_email_2)s, %(contact_person)s, %(contact_phone)s, %(box)s, %(advisor)s, %(affiliation)s)] [parameters: {'club_name': 'test_club', 'types': 'Academic, Special Interest', 'desc': 'description', 'contact_email': '[email protected]', 'contact_email_2': '[email protected]', 'contact_person': 'Test Person', 'contact_phone': 15552223232, 'box': 89, 'advisor': 'Test Person', 'affiliation': None}] (Background on this error at: http://sqlalche.me/e/9h9h) --> ========================================= 1 failed, 1 passed in 5.70s ========================================= ➜ tests git:(mf-patch-and-test) ✗
Refactor get_property_from_entity to allow for fuzzy matching
Adds some tests with pytest && fixes a json.loads bug
updated model script
working ask endpoint
patches && tests
Co-authored-by: Kalen Goo <[email protected]>
Update README.md
Iss182 catchall logger
Quick TypeError fix in NLP 👍
Co-authored-by: Kalen Goo <[email protected]>
Updated workflow to use secret, cron now outputs reasonably
Updated to work properly with SSH cert. Moved scripts to certs direct…
Ethan quick fix
Co-authored-by: Kalen Goo <[email protected]>
Autocomplete for entity synonyms and create get route to fetch entity structure
Made scripts executable, and updated git url
Handle InvalidRequestErrors by re-initializing the database session.
Added question to error handler. Added get_question method to get the current question from the request object. Initiate a rollback for all exceptions, since we don't know what has succeeded/failed, and we could be in a bad state.
Empty string answers now return None 👍
Updates to error handling.
Delete annoying print statement
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's New?
It's all the hard work that the entire Nimbus team has done to bring this product to reality.
How Has This Been Tested?
To the best of our ability, given the time constraints.
We might consider a few more tests before calling this v1.0
Checklist (check-all-before-merge)
formatting help:
- [x]
means "checked' and- [ ]
means "unchecked"I am confident that this code will deploy to production without issues
I documented my code according to the Google Python Style Guide
I ran
./build_docs.sh
and the docs look fineI ran
./type_check.sh
and got no errorsI ran
./format.sh
because it automatically cleans my code for me 😄I ran
./lint.sh
to check for what "format" missedI added my tests to the
/tests
directory