-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[pkg/ottl] Improve slice and maps dynamic indexing validation #37646
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
Comments
Pinging code owners: See Adding Labels via Comments if you do not have permissions to add labels yourself. |
I'd like to look into implementing this if this gets accepted |
@edmocosta can this actually be done during the collector startup? In most cases I think we will not know what will be the type of the values we are going to index during the statement execution. So in the example from the issue description, we will only know the type of |
I'm sorry, that was a bad example! I'll update it. |
Thank you for the clarification, @edmocosta! I will look into how this could be achieved. Another limitation however may be that we can only do this for statements that consist of known paths, like
|
One possible idea would be delegating the validation to the context's path parsers, as they're already responsible for validating/creating the path's get & setters and know their types beforehand (mostly of the time). Let's see what other folks says, I think it would be useful to have such validation, but I'm not completely sure if it would worth the extra complexity of adding it (at least for now). |
After looking further into this, i think we will have to actually execute the statement sequence upon validation, to know the types of the values being used for indexing. Like in the above example there would otherwise no way of knowing what type |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners: See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
We've recently introduced support for indexing maps and slices with dynamic values (#36644), allowing statements to access elements using
Int
,String
,Converter
, andPath
, which was a great addition to OTTL.Given slices and maps are indexed using different data types (slices w/ integers, and maps w/ strings), we should improve the OTTL contexts/parser to validate the path's key's types and avoid raising errors at runtime:
Describe the solution you'd like
When users configure statements using invalid key types, for example, slices with string keys, or maps with integer keys, we should raise an error at the collector startup:
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: