Skip to content

Commit

Permalink
fix(core): setting non-existing config property to null (#3595)
Browse files Browse the repository at this point in the history
* chore: add ui-server url in swagger
  • Loading branch information
olevski committed Aug 24, 2023
1 parent d912b46 commit e0ff587
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
6 changes: 2 additions & 4 deletions renku/command/config.py
Expand Up @@ -95,12 +95,10 @@ def _update_config(
"""
section, section_key = _split_section_and_key(key)
if remove:
value = remove_value(section, section_key, global_only=global_only)
if value is None:
raise errors.ParameterError(f'Key "{key}" not found.')
remove_value(section, section_key, global_only=global_only)
else:
set_value(section, section_key, value, global_only=global_only)
return value
return value


def update_config():
Expand Down
2 changes: 1 addition & 1 deletion renku/ui/service/views/apispec.py
Expand Up @@ -78,7 +78,7 @@ def path_helper(self, path, operations, *, view, app=None, **kwargs):
openapi_version=OPENAPI_VERSION,
version=API_VERSION,
plugins=[MultiURLFlaskPlugin(), MarshmallowPlugin()],
servers=[{"url": SERVICE_API_BASE_PATH}],
servers=[{"url": SERVICE_API_BASE_PATH}, {"url": f"/ui-server{SERVICE_API_BASE_PATH}"}],
security=[{"oidc": []}, {"JWT": [], "gitlab-token": []}],
info={"description": TOP_LEVEL_DESCRIPTION},
)
Expand Down
13 changes: 6 additions & 7 deletions tests/service/views/test_config_views.py
Expand Up @@ -20,7 +20,7 @@

import pytest

from renku.ui.service.errors import IntermittentSettingExistsError, ProgramProjectCorruptError, UserNonRenkuProjectError
from renku.ui.service.errors import ProgramProjectCorruptError, UserNonRenkuProjectError
from tests.utils import retry_failed


Expand Down Expand Up @@ -134,11 +134,10 @@ def test_config_view_set(svc_client_with_repo):
@pytest.mark.service
@pytest.mark.integration
@retry_failed
def test_config_view_set_failures(svc_client_with_repo):
"""Check errors triggered while invoking config set."""
def test_config_view_set_nonexising_key_removal(svc_client_with_repo):
"""Check that removing a non-existing key (i.e. setting to None) is allowed."""
svc_client, headers, project_id, url_components = svc_client_with_repo

# NOTE: remove a non existing value
non_existing_param = "NON_EXISTING"
payload = {
"git_url": url_components.href,
Expand All @@ -150,9 +149,9 @@ def test_config_view_set_failures(svc_client_with_repo):
response = svc_client.post("/config.set", data=json.dumps(payload), headers=headers)

assert 200 == response.status_code
assert {"error"} == set(response.json.keys())
assert IntermittentSettingExistsError.code == response.json["error"]["code"]
assert non_existing_param in response.json["error"]["devMessage"]
assert {"error"} != set(response.json.keys())
assert {"result"} == set(response.json.keys())
assert response.json["result"]["config"][non_existing_param] is None


@pytest.mark.service
Expand Down

0 comments on commit e0ff587

Please sign in to comment.