{"record":{"id":"b9c0f58bca2c2902","repo":"Tencent/WeKnora","slug":"failed-to-build-authorization-url-w","errorCode":null,"errorMessage":"failed to build authorization URL: %w","messagePattern":"failed to build authorization URL: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/mcp/oauth_manager.go","lineNumber":134,"sourceCode":"\t\t\tRedirectURI: redirectURI,\n\t\t}); err != nil {\n\t\t\tlogger.GetLogger(ctx).Warnf(\"failed to persist MCP oauth client: %v\", err)\n\t\t}\n\t}\n\n\tverifier, err := transport.GenerateCodeVerifier()\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to generate PKCE verifier: %w\", err)\n\t}\n\tchallenge := transport.GenerateCodeChallenge(verifier)\n\tstate, err := transport.GenerateState()\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to generate state: %w\", err)\n\t}\n\n\tauthURL, err := h.GetAuthorizationURL(ctx, state, challenge)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to build authorization URL: %w\", err)\n\t}\n\n\tif err := m.states.Put(ctx, state, OAuthState{\n\t\tTenantID:         tenantID,\n\t\tUserID:           principal.StorageID(),\n\t\tPrincipal:        principal,\n\t\tServiceID:        service.ID,\n\t\tCodeVerifier:     verifier,\n\t\tClientID:         h.GetClientID(),\n\t\tRedirectURI:      redirectURI,\n\t\tFrontendRedirect: frontendRedirect,\n\t}); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"failed to persist authorization state: %w\", err)\n\t}\n\n\treturn authURL, state, nil\n}\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/mcp/oauth_manager.go#L116-L152","documentation":"Returned by StartAuthorization when h.GetAuthorizationURL fails to assemble the provider's authorization endpoint URL (bad discovery metadata, malformed endpoint, or missing registration data). The user cannot be redirected, so the flow aborts after the PKCE verifier/challenge were generated.","triggerScenarios":"Thrown at internal/mcp/oauth_manager.go:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the MCP service's OAuth discovery metadata (authorization_endpoint)","Check the registered client and redirect URI are valid","Retry after fixing the service's OAuth configuration"],"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"}