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(core): setting non-existing config property to null #3595

Merged
merged 4 commits into from Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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