From f93a6c50ce32f1cf26d3dfcbc6ac662a5f674fdc Mon Sep 17 00:00:00 2001 From: shaw Date: Fri, 26 Jun 2026 16:06:01 +0800 Subject: [PATCH] fix: repair CI build & lint regressions on main - openai_gateway_model_availability.go: pass platform through to listSchedulableAccounts so OpenAI/Grok diagnosis scopes to the correct candidate pool (build break introduced by Grok subscription PR #3310). - no_account_error.go: drop redundant context.Context type on ctx := context.Background() to satisfy staticcheck ST1023. --- backend/internal/handler/no_account_error.go | 2 +- .../service/openai_gateway_model_availability.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/internal/handler/no_account_error.go b/backend/internal/handler/no_account_error.go index 89b6d1f77d..a3bf3b049e 100644 --- a/backend/internal/handler/no_account_error.go +++ b/backend/internal/handler/no_account_error.go @@ -101,7 +101,7 @@ func classifyNoAccountErrorFromGin( displayModel string, platform string, ) noAccountErrorClassification { - var ctx context.Context = context.Background() + ctx := context.Background() if c != nil && c.Request != nil { ctx = c.Request.Context() } diff --git a/backend/internal/service/openai_gateway_model_availability.go b/backend/internal/service/openai_gateway_model_availability.go index edb4ab0203..1bbc3ee7ca 100644 --- a/backend/internal/service/openai_gateway_model_availability.go +++ b/backend/internal/service/openai_gateway_model_availability.go @@ -6,9 +6,10 @@ import ( ) // DiagnoseModelAvailabilityForPlatform reports whether the requested model -// is configured to be served by any OpenAI account in the group. The -// platform argument is accepted to satisfy ModelAvailabilityDiagnoser but -// is ignored — OpenAIGatewayService only scans OpenAI accounts. +// is configured to be served by any OpenAI-compatible account in the group +// for the given platform (e.g. PlatformOpenAI, PlatformGrok). The platform +// scopes the candidate pool so distinct OpenAI-compatible platforms do not +// cross-contaminate diagnosis results. // // Safe to call on the error path: returns {true,true} on any internal // failure or when the inputs preclude meaningful diagnosis (empty model, @@ -17,7 +18,7 @@ func (s *OpenAIGatewayService) DiagnoseModelAvailabilityForPlatform( ctx context.Context, groupID *int64, requestedModel string, - _ string, + platform string, ) ModelAvailabilityDiagnosis { if s == nil { return ModelAvailabilityDiagnosis{HasAccountsInPool: true, HasModelSupport: true} @@ -27,7 +28,7 @@ func (s *OpenAIGatewayService) DiagnoseModelAvailabilityForPlatform( return ModelAvailabilityDiagnosis{HasAccountsInPool: true, HasModelSupport: true} } - accounts, err := s.listSchedulableAccounts(ctx, groupID) + accounts, err := s.listSchedulableAccounts(ctx, groupID, platform) if err != nil { // Conservative fallback so the caller keeps returning 503; we do not // want a transient lookup failure to flip into 404 model_not_found.