cluster/Backend: Handle unspecified table/set

Same as what we do in Broker. Use the expected type if publishing
a table() or set() parameter.

This fixes issues when switching sumstats to Cluster::publish()
This commit is contained in:
Arne Welzel 2024-12-11 18:21:40 +00:00
parent d9a74cf32d
commit fdf783df65
4 changed files with 105 additions and 1 deletions

View file

@ -36,9 +36,15 @@ std::optional<zeek::Args> detail::check_args(const zeek::FuncValPtr& handler, ze
for ( size_t i = 0; i < args.size(); i++ ) {
const auto& a = args[i];
const auto& got_type = a->GetType();
auto got_type = a->GetType();
const auto& expected_type = types[i];
// If called with an unspecified table or set, adopt the expected type
// as otherwise same_type() fails.
if ( got_type->Tag() == TYPE_TABLE && got_type->AsTableType()->IsUnspecifiedTable() )
if ( expected_type->Tag() == TYPE_TABLE && got_type->IsSet() == expected_type->IsSet() )
got_type = expected_type;
if ( ! same_type(got_type, expected_type) ) {
zeek::reporter->Error("event parameter #%zu type mismatch, got %s, expecting %s", i + 1,
zeek::obj_desc_short(got_type.get()).c_str(),