Lightpanda: the headless browser designed for AI and automation
force min of 1 on robot entry limit
Muki Kiboigo7e4f1dedc1dc
diff --git a/src/Config.zig b/src/Config.zigindex c15d51314..23582f8bd 100644--- a/src/Config.zig+++ b/src/Config.zig@@ -233,6 +233,28 @@ fn caPathValidator(}}+fn robotStoreEntryLimitValidator(_: Allocator, args: *std.process.Args.Iterator, target: *?u32) !void {+ const str = args.next() orelse return error.MissingArgument;+ const value = std.fmt.parseInt(u32, str, 10) catch {+ log.fatal(.app, "invalid option value", .{+ .arg = "--robot-store-entry-limit",+ .value = str,+ .hint = "must be a positive integer",+ });+ return error.InvalidArgument;+ };++ if (value == 0) {+ log.fatal(.app, "invalid option value", .{+ .arg = "--robot-store-entry-limit",+ .value = str,+ .hint = "must be at least 1",+ });+ return error.InvalidArgument;+ }+ target.* = value;+}+pub const HttpVersion = enum {auto,@"1.1",@@ -253,7 +275,7 @@ pub const ExperimentalFeatures = packed struct(u2) {/// Common CLI args.const CommonOptions = .{.{ .name = "obey_robots", .type = bool },- .{ .name = "robot_store_entry_limit", .type = ?u32, .default = 1000 },+ .{ .name = "robot_store_entry_limit", .type = ?u32, .default = 1000, .validator = robotStoreEntryLimitValidator },.{ .name = "proxy_bearer_token", .type = ?[:0]const u8 },.{ .name = "http_proxy", .type = ?[:0]const u8 },.{ .name = "http_max_concurrent", .type = ?u8 },diff --git a/src/network/LruCache.zig b/src/network/LruCache.zigindex 27ec7a7d0..e5e6dc65a 100644--- a/src/network/LruCache.zig+++ b/src/network/LruCache.zig@@ -36,6 +36,7 @@ pub fn LruCache(comptime K: type) type {map: Map = .empty,pub fn init(allocator: Allocator, capacity: usize) Self {+ std.debug.assert(capacity > 0);return .{ .allocator = allocator, .capacity = capacity };}