mirror of
https://github.com/clearml/clearml-server
synced 2025-02-07 05:27:23 +00:00
Make sure that hyperparam/configuration/metadata keys that are contain only empty space are rejected
This commit is contained in:
parent
2263e7cc1e
commit
d0252a6dd9
@ -1,6 +1,8 @@
|
||||
from boltons.dictutils import OneToOne
|
||||
from mongoengine.queryset.transform import MATCH_OPERATORS
|
||||
|
||||
from apiserver.apierrors import errors
|
||||
|
||||
|
||||
class ParameterKeyEscaper:
|
||||
"""
|
||||
@ -15,8 +17,13 @@ class ParameterKeyEscaper:
|
||||
@classmethod
|
||||
def escape(cls, value: str):
|
||||
""" Quote a parameter key """
|
||||
value = value.strip().replace("%", "%%")
|
||||
value = value.strip()
|
||||
if not value:
|
||||
raise errors.bad_request.ValidationError(
|
||||
f"Empty key is not allowed"
|
||||
)
|
||||
|
||||
value = value.replace("%", "%%")
|
||||
for c, r in cls._mapping.items():
|
||||
value = value.replace(c, r)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user