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

[优化] HTTP API 数据源同步报错 #390

Closed
wklken opened this issue Apr 29, 2022 · 3 comments
Closed

[优化] HTTP API 数据源同步报错 #390

wklken opened this issue Apr 29, 2022 · 3 comments
Assignees
Labels
Layer: login Login module related Priority: High Type: enhancement Enhancement for existing feature
Milestone

Comments

@wklken
Copy link
Collaborator

wklken commented Apr 29, 2022

对应API 没有按照要求, 返回count/results, 此时取空

实际上这里的逻辑会results的第一条, 处理; 但是没有很好地校验

会报错

Task bkuser_core.categories.tasks.adapter_sync[78744136-5e83-4605-8503-d4d8ed90f9e3] raised unexpected: IndexError('list index out of range',)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 412, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 704, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/celery/app/autoretry.py", line 50, in run
    raise task.retry(exc=exc, **retry_kwargs)
  File "/usr/local/lib/python3.6/site-packages/celery/app/task.py", line 706, in retry
    raise_with_context(exc)
  File "/usr/local/lib/python3.6/site-packages/celery/app/autoretry.py", line 35, in run
    return task._orig_run(*args, **kwargs)
  File "/app/bkuser_core/categories/tasks.py", line 111, in adapter_sync
    plugin.sync(instance_id=instance_id, task_id=task_id, *args, **kwargs)
  File "/app/bkuser_core/categories/plugins/plugin.py", line 124, in sync
    syncer.sync(*args, **kwargs)
  File "/app/bkuser_core/categories/plugins/custom/sycner.py", line 45, in sync
    self._sync_department()
  File "/app/bkuser_core/categories/plugins/custom/sycner.py", line 50, in _sync_department
    self._load2sync_manager(self.client.fetch_departments())
  File "/app/bkuser_core/categories/plugins/custom/sycner.py", line 74, in _load2sync_manager
    category=self.category, db_sync_manager=self.db_sync_manager, items=items, context=self.context
  File "/app/bkuser_core/categories/plugins/custom/helpers.py", line 277, in init_helper
    return _map[items.custom_type](
  File "/app/bkuser_core/categories/plugins/custom/models.py", line 81, in custom_type
    return type(list(self.items_map.values())[0])
IndexError: list index out of range
@wklken wklken added Type: enhancement Enhancement for existing feature Layer: login Login module related Type: 👴🏻legacy Priority: High labels Apr 29, 2022
@wklken wklken self-assigned this Apr 29, 2022
@wklken
Copy link
Collaborator Author

wklken commented May 5, 2022

  • 做准入校验, 而不是扩散到 N 层抽象封装执行时报错
  • 有没有版本系统性解决这种问题? 排查问题过于困难, 完全靠经验(看代码时间成本/调试成本巨大, 如果外部用户遇到, 拿到报错堆栈帮助也不大)

@wklken wklken added this to the Y2022M18-19 milestone May 5, 2022
@wklken
Copy link
Collaborator Author

wklken commented May 6, 2022

#400

@wklken wklken closed this as completed May 6, 2022
@wklken wklken reopened this May 7, 2022
@wklken
Copy link
Collaborator Author

wklken commented May 7, 2022

results为空的时候, 还是会报错

需要有机制 => 这是正常的返回? 还是应该认为异常不处理? (即, 同步接口空, 会导致所有用户被软删除, 系统不可用)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: login Login module related Priority: High Type: enhancement Enhancement for existing feature
Projects
None yet
Development

No branches or pull requests

1 participant