-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pkg/ottl] Handle nil val in IsMatch #17572
[pkg/ottl] Handle nil val in IsMatch #17572
Conversation
Foresight Summary
View More Details✅ check-links workflow has finished in 46 seconds (1 minute 14 seconds less than
|
Job | Failed Steps | Tests | |
---|---|---|---|
changed files | - 🔗 | N/A | See Details |
check-links | - 🔗 | N/A | See Details |
✅ tracegen workflow has finished in 56 seconds (1 minute 36 seconds less than main
branch avg.) and finished at 13th Jan, 2023.
Job | Failed Steps | Tests | |
---|---|---|---|
build-dev | - 🔗 | N/A | See Details |
publish-latest | - 🔗 | N/A | See Details |
publish-stable | - 🔗 | N/A | See Details |
✅ telemetrygen workflow has finished in 58 seconds (1 minute 39 seconds less than main
branch avg.) and finished at 13th Jan, 2023.
Job | Failed Steps | Tests | |
---|---|---|---|
build-dev | - 🔗 | N/A | See Details |
publish-latest | - 🔗 | N/A | See Details |
publish-stable | - 🔗 | N/A | See Details |
✅ prometheus-compliance-tests workflow has finished in 3 minutes 43 seconds (4 minutes 12 seconds less than main
branch avg.) and finished at 13th Jan, 2023.
Job | Failed Steps | Tests | |
---|---|---|---|
prometheus-compliance-tests | - 🔗 | ✅ 21 ❌ 0 ⏭ 0 🔗 | See Details |
✅ load-tests workflow has finished in 8 minutes 56 seconds (6 minutes 6 seconds less than main
branch avg.) and finished at 13th Jan, 2023.
Job | Failed Steps | Tests | |
---|---|---|---|
loadtest (TestIdleMode) | - 🔗 | ✅ 1 ❌ 0 ⏭ 0 🔗 | See Details |
loadtest (TestTraceAttributesProcessor) | - 🔗 | ✅ 3 ❌ 0 ⏭ 0 🔗 | See Details |
loadtest (TestMetric10kDPS|TestMetricsFromFile) | - 🔗 | ✅ 6 ❌ 0 ⏭ 0 🔗 | See Details |
loadtest (TestTraceNoBackend10kSPS|TestTrace1kSPSWithAttrs) | - 🔗 | ✅ 8 ❌ 0 ⏭ 0 🔗 | See Details |
loadtest (TestMetricResourceProcessor|TestTrace10kSPS) | - 🔗 | ✅ 12 ❌ 0 ⏭ 0 🔗 | See Details |
loadtest (TestTraceBallast1kSPSWithAttrs|TestTraceBallast1kSPSAddAttrs) | - 🔗 | ✅ 10 ❌ 0 ⏭ 0 🔗 | See Details |
loadtest (TestBallastMemory|TestLog10kDPS) | - 🔗 | ✅ 19 ❌ 0 ⏭ 0 🔗 | See Details |
setup-environment | - 🔗 | N/A | See Details |
✅ build-and-test workflow has finished in 40 minutes 11 seconds (8 minutes 44 seconds less than main
branch avg.) and finished at 13th Jan, 2023.
Job | Failed Steps | Tests | |
---|---|---|---|
integration-tests | - 🔗 | ✅ 55 ❌ 0 ⏭ 0 🔗 | See Details |
cross-compile (darwin, amd64) | - 🔗 | N/A | See Details |
cross-compile (darwin, arm64) | - 🔗 | N/A | See Details |
cross-compile (linux, amd64) | - 🔗 | N/A | See Details |
cross-compile (linux, 386) | - 🔗 | N/A | See Details |
cross-compile (linux, arm) | - 🔗 | N/A | See Details |
cross-compile (linux, arm64) | - 🔗 | N/A | See Details |
cross-compile (linux, ppc64le) | - 🔗 | N/A | See Details |
cross-compile (windows, 386) | - 🔗 | N/A | See Details |
cross-compile (windows, amd64) | - 🔗 | N/A | See Details |
build-package (deb) | - 🔗 | N/A | See Details |
build-package (rpm) | - 🔗 | N/A | See Details |
windows-msi | - 🔗 | N/A | See Details |
publish-check | - 🔗 | N/A | See Details |
publish-dev | - 🔗 | N/A | See Details |
publish-stable | - 🔗 | N/A | See Details |
⭕ build-and-test-windows workflow has finished in 3 seconds (42 minutes 29 seconds less than main
branch avg.) and finished at 17th Jan, 2023.
Job | Failed Steps | Tests | |
---|---|---|---|
windows-unittest | - 🔗 | N/A | See Details |
windows-unittest-matrix | - 🔗 | N/A | See Details |
✅ changelog workflow has finished in 2 minutes 13 seconds and finished at 17th Jan, 2023.
Job | Failed Steps | Tests | |
---|---|---|---|
changelog | - 🔗 | N/A | See Details |
*You can configure Foresight comments in your organization settings page.
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | | ||
- Affected components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the usual approach with changes to libraries like this? Should each impacted component get its own changelog entry? I'm good with doing it like this, but could also see the other side of things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have an established pattern. I did this once before in the 0.65.0 release.
@@ -38,6 +38,9 @@ func IsMatch[K any](target ottl.Getter[K], pattern string) (ottl.ExprFunc[K], er | |||
if err != nil { | |||
return nil, err | |||
} | |||
if val == nil { | |||
return false, nil | |||
} | |||
|
|||
switch v := val.(type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this PR, but keep in mind that this path is a slippery path, and will for sure hurt us. The fact that you accept multiple types instead of asking users to call this as IsMatch(..., string(value)) and enforce always having string here. The reason is because I feel like this will get duplicate in multiple places and will diverge.
You can at least start by adding "String()" func and call it on the value to avoid duplicate code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to force users to use a String() Converter function every time they use IsMatch so I like that the function handles conversion for you. Conversion is only happening for the target, not the pattern.
If your concern is only the potential duplication of the type switch statement for strings, I can pull that out into a helper function for future reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's start with avoiding potential duplication, I bet we already duplicate this.
Description:
Fixes a bug where IsMatch would return an error if the target returned a nil val. This broke conditions that used IsMatch as it is reasonable to check an attribute in a where clause that might not exist.
Link to tracking Issue:
Fixes #17563
Testing:
Added new unit test