From 69ad3c12e28ac6dc26d9f9965cf3bb5fa3979e8f Mon Sep 17 00:00:00 2001 From: ioito Date: Thu, 14 Jul 2022 20:31:42 +0800 Subject: [PATCH] fix(common): pretty error msg for invalid joint filter --- pkg/cloudcommon/db/db_dispatcher.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/cloudcommon/db/db_dispatcher.go b/pkg/cloudcommon/db/db_dispatcher.go index 59ec6d9d27..0614b20261 100644 --- a/pkg/cloudcommon/db/db_dispatcher.go +++ b/pkg/cloudcommon/db/db_dispatcher.go @@ -214,6 +214,15 @@ func applyListItemsGeneralJointFilters(manager IModelManager, q *sqlchemy.SQuery if jointModelManager == nil { return nil, httperrors.NewResourceNotFoundError("invalid joint resources %s", jfc.GetJointModelName()) } + hasKey := false + for _, colume := range manager.TableSpec().Columns() { + if colume.Name() == jfc.OriginKey { + hasKey = true + } + } + if !hasKey { + return q, httperrors.NewInputParameterError("invalid joint filter %s, because %s doesn't have %s field", f, manager.Keyword(), jfc.OriginKey) + } schFields := searchFields(jointModelManager, userCred) if schFields.Contains(jfc.GetField()) { sq := jointModelManager.Query(jfc.RelatedKey)