{"record":{"id":"fd6e509289b61773","repo":"Tencent/WeKnora","slug":"unknown-credential-field-s","errorCode":null,"errorMessage":"unknown credential field: %s","messagePattern":"unknown credential field: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/mcp_service.go","lineNumber":568,"sourceCode":"\t}\n\tif existing.AuthConfig == nil {\n\t\treturn nil // nothing to clear\n\t}\n\n\tchanged := false\n\tswitch field {\n\tcase \"api_key\":\n\t\tif existing.AuthConfig.APIKey != \"\" {\n\t\t\texisting.AuthConfig.APIKey = \"\"\n\t\t\tchanged = true\n\t\t}\n\tcase \"token\":\n\t\tif existing.AuthConfig.Token != \"\" {\n\t\t\texisting.AuthConfig.Token = \"\"\n\t\t\tchanged = true\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown credential field: %s\", field)\n\t}\n\tif !changed {\n\t\treturn nil\n\t}\n\n\texisting.UpdatedAt = time.Now()\n\tif err := s.mcpServiceRepo.Update(ctx, existing); err != nil {\n\t\treturn fmt.Errorf(\"failed to update MCP service: %w\", err)\n\t}\n\n\ts.mcpManager.CloseClient(id)\n\tlogger.GetLogger(ctx).Infof(\n\t\t\"MCP credential cleared by user: id=%s field=%s, connection closed\",\n\t\tsecutils.SanitizeForLog(id), field,\n\t)\n\treturn nil\n}\n","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/mcp_service.go#L550-L586","documentation":"Validation in ClearMCPCredential's field switch: the requested credential field is neither 'api_key' nor 'token', the only two clearable fields. Any other field name is rejected to avoid silently pretending to clear an unknown key; fix by passing one of the supported field identifiers.","triggerScenarios":"Thrown at internal/application/service/mcp_service.go:568 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use 'api_key' or 'token' as the field value","Validate the field against the allowed set client-side before calling","Document supported fields in the API contract"],"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"}