Skip to content

Do not require that user vars are non-empty#218

Merged
bbannier merged 1 commit intomasterfrom
topic/bbannier/user-val-empty-str
Jan 8, 2026
Merged

Do not require that user vars are non-empty#218
bbannier merged 1 commit intomasterfrom
topic/bbannier/user-val-empty-str

Conversation

@bbannier
Copy link
Copy Markdown
Member

@bbannier bbannier commented Jan 8, 2026

When typing this code in #209 we introduced checks that variables of types like str | None were set. In making that we accidentially used a narrower requirement that user vars were not only set, but also not empty. This is because

assert val

for a val: str means "is set, and its value is truthy (i.e., the str is not empty).

Since we still catch empty users vars elsewhere this still had the same effect, but now potentially exposed users to a naked AssertionError instead of an error message.

With this patch we just require that user variables are set.

When typing this code we introduced checks that variables of types like
`str | None` were set. In making that we accidentially used a narrower
requirement that user vars were not only set, but also not empty. This
is because

    assert val

for a `val: str` means "is set, and its value is truthy (i.e., the `str`
is not empty).

Since we still catch empty users vars elsewhere this still had the same
effect, but now potentially exposed users to a naked `AssertionError`
instead of an error message.

With this patch we just require that user variables are set.
@bbannier bbannier marked this pull request as ready for review January 8, 2026 08:47
@bbannier
Copy link
Copy Markdown
Member Author

bbannier commented Jan 8, 2026

@timwoj This was a regression in the window between zeek-8.0 and zeek-8.1-rc2, we could think about including this in zeek-8.1.0, or in its first patch release. The change here seems pretty narrow to me.

Copy link
Copy Markdown
Contributor

@awelzel awelzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test would've been nice, but I guess that works.

@bbannier bbannier merged commit 62191e6 into master Jan 8, 2026
5 checks passed
@bbannier bbannier deleted the topic/bbannier/user-val-empty-str branch January 8, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants