This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/answer.git
commit 9a7eb0f450d31042c8badf080354754a8704e429 Author: LinkinStars <[email protected]> AuthorDate: Thu Nov 20 17:42:35 2025 +0800 fix(service): set default language to "en_US" if invalid language is provided --- internal/service/siteinfo/siteinfo_service.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/service/siteinfo/siteinfo_service.go b/internal/service/siteinfo/siteinfo_service.go index a0f4891c..92b3e0c7 100644 --- a/internal/service/siteinfo/siteinfo_service.go +++ b/internal/service/siteinfo/siteinfo_service.go @@ -40,7 +40,6 @@ import ( tagcommon "github.com/apache/answer/internal/service/tag_common" "github.com/apache/answer/plugin" "github.com/jinzhu/copier" - "github.com/segmentfault/pacman/errors" "github.com/segmentfault/pacman/log" ) @@ -159,10 +158,9 @@ func (s *SiteInfoService) SaveSiteGeneral(ctx context.Context, req schema.SiteGe } func (s *SiteInfoService) SaveSiteInterface(ctx context.Context, req schema.SiteInterfaceReq) (err error) { - // check language + // If the language is invalid, set it to the default language "en_US" if !translator.CheckLanguageIsValid(req.Language) { - err = errors.BadRequest(reason.LangNotFound) - return + req.Language = "en_US" } content, _ := json.Marshal(req)
