Skip to content

[BUG] KeyError when batchCreate results in errors #30

@wooooodward

Description

@wooooodward

Describe the bug
There's an uncaught KeyError when the batchCreate endpoint returns errors.

Traceback (most recent call last):
  File "/home/user/project/venv/lib/python3.7/site-packages/celery/app/trace.py", line 385, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/user/project/venv/lib/python3.7/site-packages/celery/app/trace.py", line 650, in __protected_call__
    return self.run(*args, **kwargs)
  File "/home/user/project/dispatch/tasks.py", line 18, in create_onfleet_tasks_from_run
    create_count, error_list = models.RunStop.tasks.batch_create(stops)
  File "/home/user/project/_onfleet/models.py", line 45, in batch_create
    response = api.tasks.batchCreate(body=dict(tasks=task_list))
  File "/home/user/project/venv/lib/python3.7/site-packages/backoff/_sync.py", line 94, in retry
    ret = target(*args, **kwargs)
  File "/home/user/project/venv/lib/python3.7/site-packages/ratelimit/decorators.py", line 80, in wrapper
    return func(*args, **kargs)
  File "/home/user/project/venv/lib/python3.7/site-packages/onfleet/request.py", line 62, in __call__
    error_request = error['message']['request']
KeyError: 'request'

To Reproduce
I had thought it was due to an error with the address but just retried the API call and it was completed successfully.

I've run into a similar problem with large batches but in this case the body only contained 10 tasks.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
v1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions