{"record":{"id":"466f25890dd9e365","repo":"babalae/better-genshin-impact","slug":"onebot-endpoint-is-not-set","errorCode":null,"errorMessage":"OneBot endpoint is not set","messagePattern":"OneBot endpoint is not set","errorType":"validation","errorClass":"NotifierException","httpStatus":null,"severity":"warning","filePath":"BetterGenshinImpact/Service/Notifier/OneBotNotifier.cs","lineNumber":42,"sourceCode":"    \n    public string Token { get; set; }\n\n    private readonly HttpClient _httpClient;\n    \n    public OneBotNotifier(HttpClient httpClient, string endpoint = \"\", string userId = \"\", string groupId = \"\", string token = \"\")\n    {\n        _httpClient = httpClient;\n        Endpoint = endpoint;\n        UserId = userId;\n        GroupId = groupId;\n        Token = token;\n    }\n\n    public async Task SendAsync(BaseNotificationData content)\n    {\n        if (string.IsNullOrEmpty(Endpoint))\n        {\n            throw new NotifierException(\"OneBot endpoint is not set\");\n        }\n        \n        if (string.IsNullOrEmpty(UserId) && string.IsNullOrEmpty(GroupId))\n        {\n            throw new NotifierException(\"OneBot requires either a user ID or group ID\");\n        }\n\n        try\n        {\n            // 确保URL以/send_msg结尾\n            var url = Endpoint.TrimEnd('/');\n            if (!url.EndsWith(\"/send_msg\"))\n            {\n                url += \"/send_msg\";\n            }\n\n            bool success = true;\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Service/Notifier/OneBotNotifier.cs#L24-L60","documentation":"OneBotNotifier.SendAsync fails fast when the Endpoint property (the OneBot HTTP API base URL, e.g. http://127.0.0.1:5700) is null or empty. Without it the notifier cannot build the /send_msg URL.","triggerScenarios":"OneBotNotifier constructed with endpoint=\"\" (the default) and SendAsync invoked; the IsNullOrEmpty(Endpoint) guard at line 40 fires.","commonSituations":"User enabled the OneBot channel without configuring the reverse-HTTP endpoint URL; settings string was trimmed to empty; the OneBot implementation (go-cqhttp, NapCat, Lagrange) is not running or moved port.","solutions":["Set the OneBot HTTP endpoint in settings (e.g. http://127.0.0.1:5700) and ensure the OneBot client has HTTP POST enabled.","Validate the endpoint is a reachable absolute URL before constructing the notifier.","Confirm the OneBot framework's http config host/port matches what was entered."],"exampleFix":"// before\nvar n = new OneBotNotifier(httpClient, endpoint, userId, groupId, token);\n\n// after\nif (!Uri.TryCreate(endpoint, UriKind.Absolute, out _))\n    throw new InvalidOperationException(\"OneBot endpoint must be an absolute URL.\");\nvar n = new OneBotNotifier(httpClient, endpoint, userId, groupId, token);","handlingStrategy":"validation","validationCode":"if (!Uri.TryCreate(endpoint, UriKind.Absolute, out var uri)\n    || (uri.Scheme != \"http\" && uri.Scheme != \"https\"))\n    throw new InvalidOperationException(\"OneBot endpoint must be an absolute http(s) URL.\");","typeGuard":"static bool IsOneBotEndpointValid(string endpoint)\n    => Uri.TryCreate(endpoint, UriKind.Absolute, out var u)\n       && (u.Scheme == Uri.UriSchemeHttp || u.Scheme == Uri.UriSchemeHttps);","tryCatchPattern":"try { await oneBotNotifier.SendAsync(data); }\ncatch (NotifierException ex) when (ex.Message.Contains(\"endpoint is not set\"))\n{ /* prompt user to configure endpoint, no retry */ }","preventionTips":["Validate the endpoint URL at settings-save time.","Confirm the OneBot framework's HTTP server is enabled on that host:port."],"tags":["onebot","config","validation","notifier"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}