Skip to content
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

HERE error handling leading to a bug #1122

Open
radumas opened this issue Dec 31, 2024 · 0 comments · May be fixed by #1129
Open

HERE error handling leading to a bug #1122

radumas opened this issue Dec 31, 2024 · 0 comments · May be fixed by #1129
Assignees

Comments

@radumas
Copy link
Member

radumas commented Dec 31, 2024

example log

[2024-12-27, 16:39:47 EST] {base.py:84} INFO - Retrieving connection 'here_api_key'
[2024-12-27, 16:40:48 EST] {here_api.py:125} INFO - Polling status of query request: 598638
[2024-12-27, 16:40:48 EST] {here_api.py:50} INFO - Getting Access Token
[2024-12-27, 16:41:48 EST] {here_api.py:125} INFO - Polling status of query request: 598638
[2024-12-27, 16:41:48 EST] {here_api.py:50} INFO - Getting Access Token
[2024-12-27, 16:42:48 EST] {here_api.py:125} INFO - Polling status of query request: 598638
[2024-12-27, 16:42:48 EST] {here_api.py:50} INFO - Getting Access Token
[2024-12-27, 16:43:48 EST] {here_api.py:125} INFO - Polling status of query request: 598638
[2024-12-27, 16:43:48 EST] {here_api.py:50} INFO - Getting Access Token
[2024-12-27, 16:44:48 EST] {here_api.py:125} INFO - Polling status of query request: 598638
[2024-12-27, 16:44:54 EST] {here_api.py:50} INFO - Getting Access Token
[2024-12-27, 16:45:54 EST] {here_api.py:125} INFO - Polling status of query request: 598638
[2024-12-27, 16:45:54 EST] {here_api.py:50} INFO - Getting Access Token
[2024-12-27, 16:46:54 EST] {here_api.py:125} INFO - Polling status of query request: 598638
[2024-12-27, 16:46:54 EST] {here_api.py:50} INFO - Getting Access Token
[2024-12-27, 16:47:54 EST] {here_api.py:125} INFO - Polling status of query request: 598638
[2024-12-27, 16:47:54 EST] {here_api.py:50} INFO - Getting Access Token
[2024-12-27, 16:47:54 EST] {here_api.py:152} INFO - Requested query completed
[2024-12-27, 16:47:54 EST] {taskinstance.py:3310} ERROR - Task failed with exception

Notice the alternating between "Polling status" and "Getting Access Token". There's an HTTPError being thrown that is not because the token expired. This happens 8 times, and then the counter is exhausted.

try:
query_status.raise_for_status()
status = str(query_status.json()['status'])
except requests.exceptions.HTTPError:
#access token expires after 1 hr, try to generate up to 3 times.
access_token = get_access_token(api_conn)
token_counter+=1

At this point, the loop is exited and we get

LOGGER.info('Requested query completed')
return query_status.json()['outputUrl']

Traceback (most recent call last):
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/models/taskinstance.py", line 767, in _execute_task
    result = _execute_callable(context=context, **execute_callable_kwargs)
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/models/taskinstance.py", line 733, in _execute_callable
    return ExecutionCallableRunner(
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/utils/operator_helpers.py", line 252, in run
    return self.func(*args, **kwargs)
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/models/baseoperator.py", line 406, in wrapper
    return func(self, *args, **kwargs)
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/decorators/base.py", line 266, in execute
    return_value = super().execute(context)
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/models/baseoperator.py", line 406, in wrapper
    return func(self, *args, **kwargs)
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/operators/python.py", line 238, in execute
    return_value = self.execute_callable()
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/operators/python.py", line 256, in execute_callable
    return runner.run(*self.op_args, **self.op_kwargs)
  File "/data/airflow/airflow_venv/lib/python3.10/site-packages/airflow/utils/operator_helpers.py", line 252, in run
    return self.func(*args, **kwargs)
  File "/data/airflow/dags/pull_here_path.py", line 72, in get_download_link
    download_url = get_download_url(request_id, api_conn.extra_dejson['status_base_url'], access_token, api_conn.login, api_conn)
  File "/data/airflow/data_scripts/here/traffic/here_api.py", line 154, in get_download_url
    return query_status.json()['outputUrl']
KeyError: 'outputUrl'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants