fix: avoid AttributeError when password is not provided in compute update

When updating a compute without providing a password field,
compute_update.password is None and calling .get_secret_value()
on it causes a 500 Internal Server Error. Only set the password
in update_values when a password is actually provided.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
YueGuobinandClaude Opus 4.6 committed 2026-05-02 15:37:46 +08:00
1 parent f0ef65b8e8
commit a6dcab8110
1 file changed
+2 -1
+2 -1
View File
@@ -69,7 +69,8 @@ class ComputesRepository(BaseRepository):
async def update_compute(self, compute_id: UUID, compute_update: schemas.ComputeUpdate) -> Optional[models.Compute]:
update_values = compute_update.model_dump(exclude_unset=True)
update_values["password"] = compute_update.password.get_secret_value()
if compute_update.password is not None:
update_values["password"] = compute_update.password.get_secret_value()
query = update(models.Compute).\
where(models.Compute.compute_id == compute_id).\