Skip to content

Commit 9d6451b

Browse files
authored
fix: The interface for obtaining model metadata cannot access public models (#2787)
1 parent add1cba commit 9d6451b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/setting/serializers/provider_serializers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,16 @@ def one(self, with_valid=False):
313313
return ModelSerializer.model_to_dict(model)
314314

315315
def one_meta(self, with_valid=False):
316+
model = None
316317
if with_valid:
317318
super().is_valid(raise_exception=True)
318319
model = QuerySet(Model).filter(id=self.data.get("id")).first()
319320
if model is None:
320321
raise AppApiException(500, _('Model does not exist'))
321322
if model.permission_type == 'PRIVATE' and str(model.user_id) != str(self.data.get("user_id")):
322323
raise Exception(_('No permission to use this model') + f"{model.name}")
323-
model = QuerySet(Model).get(id=self.data.get('id'))
324+
if model is None:
325+
model = QuerySet(Model).get(id=self.data.get('id'))
324326
return {'id': str(model.id), 'provider': model.provider, 'name': model.name, 'model_type': model.model_type,
325327
'model_name': model.model_name,
326328
'status': model.status,

0 commit comments

Comments
 (0)