Skip to content

Commit 6f9b8fb

Browse files
Trinity Agentclaude
andcommitted
fix(bot): replace catch unreachable with proper error handling in claude_stream.zig (#150)
The URI parsing on line 67 used `catch unreachable` which is unsafe because api_url is built dynamically from environment variables and could be malformed. Now properly logs the error and returns gracefully with a Telegram notification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c16ed8f commit 6f9b8fb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tools/mcp/trinity_mcp/bot/claude_stream.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ pub fn runStreaming(
6464
};
6565
defer allocator.free(api_url);
6666

67-
const uri = std.Uri.parse(api_url) catch unreachable;
67+
const uri = std.Uri.parse(api_url) catch |err| {
68+
std.log.err("Invalid API URL: {s} — {}", .{ api_url, err });
69+
telegram_api.sendMessage(allocator, config.bot_token, config.chat_id, "\xe2\x9d\x8c Invalid API URL");
70+
return;
71+
};
6872

6973
var req = client.request(.POST, uri, .{
7074
.extra_headers = &.{

0 commit comments

Comments
 (0)