-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(models): reject measurements and keys with leading underscores #20314
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
Conversation
This will likely break a lot of people's Kap workflows, because they tend to write fields like _start and _stop, iirc. |
err = walkFields(fields, func(k, v []byte) bool { | ||
if k[0] == '_' { |
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.
Do you need to check len(k)>0
here first?
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.
This one seems to be covered by a preceding check, I get "missing field key" if I try to parse a line with an empty key
@@ -534,10 +551,13 @@ func scanKey(buf []byte, i int) (int, []byte, error) { | |||
} | |||
|
|||
// Iterate over tags keys ensure that we do not encounter any | |||
// of the reserved tag keys such as _measurement or _field. | |||
// of the reserved tag keys. | |||
for j := 0; j < commas; j++ { | |||
_, key := scanTo(buf[indices[j]:indices[j+1]-1], 0, '=') | |||
|
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.
Do you need to check len(k)>0
here first?
before line 558 or is that impossible?
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.
This one seems to be covered by a preceding check, I get "missing tag key" if I try to parse cpu,=testing,tag=value value=2
Closing for now, needs more discussion |
Closes #20310
This brings our implementation in line with the spec, and prevents panics when users override keys like
_start
. The first commit is a refactoring that I could split into a separate PR, if desired. The diff in the test file shows the impact of the actual fix.