Fix validation for empty variable name and value in create_variable function
This commit is contained in:
parent
6261c71e01
commit
4bbba570fe
1 changed files with 5 additions and 1 deletions
|
|
@ -37,7 +37,11 @@ def create_variable(
|
|||
variable_dict["user_id"] = current_user.id
|
||||
|
||||
db_variable = Variable.model_validate(variable_dict)
|
||||
if not db_variable.value:
|
||||
if not db_variable.name and not db_variable.value:
|
||||
raise HTTPException(status_code=400, detail="Variable name and value cannot be empty")
|
||||
elif not db_variable.name:
|
||||
raise HTTPException(status_code=400, detail="Variable name cannot be empty")
|
||||
elif not db_variable.value:
|
||||
raise HTTPException(status_code=400, detail="Variable value cannot be empty")
|
||||
encrypted = auth_utils.encrypt_api_key(db_variable.value, settings_service=settings_service)
|
||||
db_variable.value = encrypted
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue