-
Notifications
You must be signed in to change notification settings - Fork 24.2k
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
Warn or fail if runtime field doesn't have emit #72723
Comments
Pinging @elastic/es-search (Team:Search) |
I tend to see the proposed solution as a way to work around the fact that we don't automatically emit values when we could. I would much rather prefer that we rather focus first on auto-emitting. |
Would you prefer that we leave things as they are for six mon |
We have discussed this with the team, we said we are ok going ahead with it. I also opened #73536 to track the need for automatically emitting values. Like I commented there, failing when |
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Both warning, as well as auto emitting, would be difficult to do in painless in a script agnostic way. It's not impossible (similar in some ways to auto return, as far as detection), but it would require some new designs to designate what gets added to the tree, perhaps by generalizing auto return. Remember that I've added this for discussion by the scripting team. |
A straightforward way of doing this would be to track the methods called by a script and expose that to the caller. The caller (rt fields in this case) can then inspect the methods and fails if |
At this point runtime fields require you to call
emit
to return values. As much as it'd be nice to auto-emit in some obvious cases, we don't now. So maybe we should fail to compile scripts that don't ever callemit
. Or at return a warning or something. These scripts are almost certainly an accident. Possibly one from copying one of kibana's "scripted fields".I'm imagining something like this being ok:
It calls emit in an
if
. But something like this:would fail. Or return a warning. Or something. Because its never going to result in a value at all. It can't because you never invoke the
emit
function in any code path.The text was updated successfully, but these errors were encountered: