From ff93f4fcc29b1867adda6fa2804a865316a01337 Mon Sep 17 00:00:00 2001 From: Navid EMAD Date: Wed, 29 Apr 2026 04:41:47 +0200 Subject: [PATCH] cdp: panic on non-integer Navigation entry _id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Navigation.pushEntry always allocPrints _id as a decimal usize counter, so parseInt(i64, _id, 10) can't fail on real entries — a parse error means the internal invariant has been violated. The previous fallbacks (index in getNavigationHistory, `continue` in navigateToHistoryEntry) masked that as either a wrong-but-plausible id or a misleading InvalidParams response. Surface it instead. --- src/cdp/domains/page.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cdp/domains/page.zig b/src/cdp/domains/page.zig index 0af1db08..99097908 100644 --- a/src/cdp/domains/page.zig +++ b/src/cdp/domains/page.zig @@ -391,9 +391,10 @@ fn getNavigationHistory(cmd: *CDP.Command) !void { const entries_out = try cmd.arena.alloc(NavigationEntry, entries_in.len); for (entries_in, 0..) |entry, i| { - // Internal _id is a decimal-formatted monotonically-increasing counter - // (see Navigation.pushEntry); fall back to index if parse ever fails. - const eid = std.fmt.parseInt(i64, entry._id, 10) catch @as(i64, @intCast(i)); + // Navigation.pushEntry always formats _id as a decimal usize counter, + // so parse failure here is an internal invariant violation, not a + // recoverable runtime error. + const eid = std.fmt.parseInt(i64, entry._id, 10) catch @panic("Navigation entry _id is not a base-10 integer"); entries_out[i] = .{ .id = eid, .url = entry._url orelse "", @@ -425,7 +426,7 @@ fn navigateToHistoryEntry(cmd: *CDP.Command) !void { var target_index: ?usize = null; var target_url: ?[:0]const u8 = null; for (nav._entries.items, 0..) |entry, i| { - const eid = std.fmt.parseInt(i64, entry._id, 10) catch continue; + const eid = std.fmt.parseInt(i64, entry._id, 10) catch @panic("Navigation entry _id is not a base-10 integer"); if (eid == params.entryId) { target_index = i; target_url = entry._url;