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

Fix: Add sanity check for disabled category in creating profiles #94

Merged
merged 1 commit into from
Oct 11, 2021
Merged

Fix: Add sanity check for disabled category in creating profiles #94

merged 1 commit into from
Oct 11, 2021

Conversation

uddmorningsun
Copy link
Contributor

  • /api/v2/profiles/ (POST): {"username": "postman22", "category_id": 2, "departments": [2,3,4]}
  • category_id=2 enabled=False
ERROR [2021-10-02 21:08:37] bkuser_core.common.exception_handler(ln:70): request apiServer failed
Traceback (most recent call last):
  File "/tmp/venv/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/tmp/venv/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/tmp/123321/bk-user/src/api/bkuser_core/common/cache.py", line 38, in wrapper
    value = func(*args, **kwargs)
  File "/tmp/123321/bk-user/src/api/bkuser_core/profiles/views.py", line 253, in create
    serializer.validated_data["category_id"], return_raw=True
  File "/tmp/123321/bk-user/src/api/bkuser_core/profiles/utils.py", line 97, in make_password_by_config
    if config_loader["init_password_method"] == InitPasswordMethod.FIXED_PRESET.value:
  File "/tmp/123321/bk-user/src/api/bkuser_core/user_settings/loader.py", line 35, in __getitem__
    return self._config[key]
KeyError: 'init_password_method'

Signed-off-by: Chenyang Yan [email protected]

@IMBlues
Copy link
Contributor

IMBlues commented Oct 11, 2021

这里是在一个新建的目录里创建用户么?这个目录是不是没有初始化配置?可以看看这个方法

@uddmorningsun
Copy link
Contributor Author

这里是在一个新建的目录里创建用户么?这个目录是不是没有初始化配置?可以看看这个方法

@IMBlues 不是的,是在创建 profiles 的时候引用一个 disabled 的目录会扔出异常,因为 ConfigProvider._refresh_config 过滤时增加了 enabled=True

@IMBlues
Copy link
Contributor

IMBlues commented Oct 11, 2021

这里是在一个新建的目录里创建用户么?这个目录是不是没有初始化配置?可以看看这个方法

@IMBlues 不是的,是在创建 profiles 的时候引用一个 disabled 的目录会扔出异常,因为 ConfigProvider._refresh_config 过滤时增加了 enabled=True

明白了,应该是目录 disable 的时候同时将 setting 删除了

@IMBlues IMBlues merged commit be1de4e into TencentBlueKing:development Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants