{"record":{"id":"be537e30f582f166","repo":"Tencent/WeKnora","slug":"mcp-service-not-found-be537e","errorCode":null,"errorMessage":"MCP service not found","messagePattern":"MCP service not found","errorType":"exception","errorClass":null,"httpStatus":404,"severity":"error","filePath":"internal/mcp/oauth_manager.go","lineNumber":168,"sourceCode":"\treturn authURL, state, nil\n}\n\n// StartAuthorizationForService loads the MCP service by ID and starts the\n// authorization-code flow, returning the URL the user must open. It is a\n// convenience for callers (e.g. IM channels) that only hold a service ID and\n// cannot reach the MCP service lookup directly.\nfunc (m *OAuthManager) StartAuthorizationForService(\n\tctx context.Context,\n\ttenantID uint64,\n\tprincipal types.Principal,\n\tserviceID, redirectURI, frontendRedirect string,\n) (string, error) {\n\tservice, err := m.serviceRepo.GetByID(ctx, tenantID, serviceID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to load MCP service: %w\", err)\n\t}\n\tif service == nil {\n\t\treturn \"\", fmt.Errorf(\"MCP service not found\")\n\t}\n\tauthURL, _, err := m.StartAuthorization(ctx, service, tenantID, principal, redirectURI, frontendRedirect)\n\treturn authURL, err\n}\n\n// CompleteAuthorization handles the provider callback: it validates state,\n// exchanges the code for tokens (PKCE), and persists the per-user token.\n// Returns the frontend redirect URL and service ID recorded at\n// StartAuthorization time so the caller can recycle any cached transport that\n// still carries the previous OAuth client registration.\nfunc (m *OAuthManager) CompleteAuthorization(\n\tctx context.Context, state, code string,\n) (frontendRedirect, serviceID string, err error) {\n\tctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), oauthCallbackTimeout)\n\tdefer cancel()\n\n\tst, err := m.states.Take(ctx, state)\n\tif err != nil {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/mcp/oauth_manager.go#L150-L186","documentation":"Returned by StartAuthorizationForService when GetByID succeeds but returns a nil service — the MCP service with that ID does not exist for the tenant (or was deleted). Distinct from a repository error: the lookup worked and definitively found nothing.","triggerScenarios":"Thrown at internal/mcp/oauth_manager.go:168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the service ID with the tenant","Re-create or re-register the MCP service before retrying authorization"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}