# Buggy code
def sort_args(self):
    return args.make_sort_args(
        validator=args.IndexValidator(
            self.model,
            extra=["candidate", "committee"],
        ),
    )


# Traceback (sqlalchemy.exc.CompileError)
2020-05-18T14:16:00.43-0400 [RTR/1] OUT fec-prod-api.app.cloud.gov - [2020-05-18T18:16:00.388886389Z] "GET /v1/schedules/schedule_e/by_candidate/?sort_hide_null=false&amp;sort_nulls_last=true&amp;sort=candidate&amp;per_page=10&amp;page=1&amp;cycle=2020&amp;election_full=true&amp;duration=6&amp;office=senate&amp;state=CO&amp;stateFull=Colorado HTTP/1.1" 500 0 141 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" "127.0.0.1:20354" "10.10.2.12:61082" x_forwarded_for:"73.212.220.45, 73.212.220.45, 54.208.160.112, 127.0.0.1" x_forwarded_proto:"https" vcap_request_id:"910be5ac-6c31-4e2a-6b66-9cd78e18ce4f" response_time:0.043971 gorouter_time:0.000124 app_id:"3ecc8d29-da07-45fa-bbfc-c0aed0322413" app_index:"8" x_b3_traceid:"c7698e3b4e20aac6" x_b3_spanid:"c7698e3b4e20aac6" x_b3_parentspanid:"-" b3:"c7698e3b4e20aac6-c7698e3b4e20aac6"
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR sqlalchemy.exc.CompileError: Can't resolve label reference for ORDER BY / GROUP BY. Textual SQL expression 'candidate' should be explicitly declared as text('candidate')
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR During handling of the above exception, another exception occurred:
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR Traceback (most recent call last):
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/gunicorn/workers/base_async.py", line 56, in handle
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     self.handle_request(listener_name, req, client, addr)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/gunicorn/workers/ggevent.py", line 160, in handle_request
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     addr)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/gunicorn/workers/base_async.py", line 107, in handle_request
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     respiter = self.wsgi(environ, resp.start_response)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     return self.wsgi_app(environ, start_response)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/werkzeug/middleware/proxy_fix.py", line 232, in __call__
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     return self.app(environ, start_response)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     response = self.handle_exception(e)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask_restful/__init__.py", line 269, in error_router
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     return original_handler(e)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     return cors_after_request(app.make_response(f(*args, **kwargs)))
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     reraise(exc_type, exc_value, tb)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     raise value.with_traceback(tb)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     response = self.full_dispatch_request()
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     rv = self.handle_user_exception(e)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask_restful/__init__.py", line 269, in error_router
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     return original_handler(e)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     return cors_after_request(app.make_response(f(*args, **kwargs)))
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/deps/0/python/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     return handler(e)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR   File "/home/vcap/app/webservices/rest.py", line 271, in handle_exception
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR     status_code=http.client.NOT_FOUND)
2020-05-18T14:16:00.43-0400 [APP/PROC/WEB/8] ERR webservices.exceptions.ApiError

# Fixed code
def sort_args(self):
    return args.make_sort_args(
        validator=args.IndexValidator(
            self.model,
            extra=["candidate_name", "committee_name", "candidate_id", "committee_id"],
        ),
    )