Skip to content

Sync up with upstream ES main: apply project ID resolver to ScriptService. #357

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

Merged
merged 3 commits into from
Aug 7, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private static ScriptService initScriptService(final Settings settings, final Th
Map<String, ScriptEngine> engines = new HashMap<>();
engines.put(PainlessScriptEngine.NAME, getPainlessScriptEngine(settings));
engines.put(MustacheScriptEngine.NAME, new MustacheScriptEngine(settings));
return new ScriptService(settings, engines, ScriptModule.CORE_CONTEXTS, threadPool::absoluteTimeInMillis);
return new ScriptService(settings, engines, ScriptModule.CORE_CONTEXTS, threadPool::absoluteTimeInMillis, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ha i just read the PR description 😅 :

Applying as introduced in the logstash-bridge ScriptServiceBridge: https://github.com/elastic/elasticsearch/pull/130578/files#diff-f74baacde87eae5c09e26daf35f888065d68238e2593160179fb937c11d11327R73

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 PDT logstash-1 | org.elasticsearch.ElasticsearchException: java.lang.NullPointerException: Cannot invoke "org.elasticsearch.cluster.project.ProjectResolver.getProjectId()" because "this.projectResolver" is null

Hmm maybe that wont work

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but it seems our case is non-null tolerant (see below error). I will do couple of tests with logstash-bridge changes (with my ongoing PR) and introduce DefaultProjectResolver.INSTANCE in the bridge as well.


2025-08-05 14:29:13 PDT | logstash-1       \|         Caused by: java.lang.NullPointerException: Cannot invoke "org.elasticsearch.cluster.project.ProjectResolver.getProjectId()" because "this.projectResolver" is null
-- | --
  | 2025-08-05 14:29:13 PDT | logstash-1       \|                 at org.elasticsearch.script.ScriptService.compile(ScriptService.java:596) ~[elasticsearch-9.2.0-SNAPSHOT.jar:9.2.0-SNAPSHOT]
  | 2025-08-05 14:29:13 PDT | logstash-1       \|                 at org.elasticsearch.ingest.ConditionalProcessor.<init>(ConditionalProcessor.java:82) ~[elasticsearch-9.2.0-SNAPSHOT.jar:9.2.0-SNAPSHOT]
  | 2025-08-05 14:29:13 PDT | logstash-1       \|                 at org.elasticsearch.ingest.ConditionalProcessor.<init>(ConditionalProcessor.java:62) ~[elasticsearch-9.2.0-SNAPSHOT.jar:9.2.0-SNAPSHOT]
  | 2025-08-05 14:29:13 PDT | logstash-1       \|                 at org.elasticsearch.ingest.ConfigurationUtils.readProcessor(ConfigurationUtils.java:658) ~[elasticsearch-9.2.0-SNAPSHOT.jar:9.2.0-SNAPSHOT]
  | 2025-08-05 14:29:13 PDT | logstash-1       \|                 ... 104 more

Copy link
Collaborator Author

@mashhurs mashhurs Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both null and DefaultProjectResolver.INSTANCE didn't work for this case. DefaultProjectResolver.INSTANCE requires additional classes such as Metadata class loading where plugin needs to include its jar package. Introducing a separate plugin based project resolver seems a better approach for now.
FYI: I have also tested with the logstash-bridge - mashhurs/elasticsearch@78a5fb9

}

/**
Expand Down