Do not require that user vars are non-empty#218
Merged
Conversation
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.
Member
Author
|
@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. |
awelzel
approved these changes
Jan 8, 2026
Contributor
awelzel
left a comment
There was a problem hiding this comment.
A test would've been nice, but I guess that works.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When typing this code in #209 we introduced checks that variables of types like
str | Nonewere set. In making that we accidentially used a narrower requirement that user vars were not only set, but also not empty. This is becausefor a
val: strmeans "is set, and its value is truthy (i.e., thestris not empty).Since we still catch empty users vars elsewhere this still had the same effect, but now potentially exposed users to a naked
AssertionErrorinstead of an error message.With this patch we just require that user variables are set.