Menu

#1333 CLI console-mode script execution (--script, PROJECT_CHANGE event) silently no-ops

6.2
open
6.2.0-dev
5
2026-08-23
2026-08-23
No

CommandCommon.executeConsoleScript() reflectively invokes
org.omegat.gui.scripting.ScriptingModule#executeConsoleScript(PROJECT_CHANGE_TYPE, File).
That method does not exist on ScriptingModule, so the call throws
NoSuchMethodException, which is caught and only logged (Log.log(e)).
The failure is silent: OmegaT starts normally in console mode, but any
script registered to run on a PROJECT_CHANGE event (e.g. via --script) is
never executed.

Root cause:
The original executeConsoleScript method lived in Main.java and called
the (then-current) scripting API directly:
ScriptRunner.executeScript(new ScriptItem(script), binding), using
ScriptRunner / ScriptItem / ConsoleBindings. This is still the
implementation on releases/6.1 (confirmed present and compiling in the
6.1.1 Main.java) and works correctly there.

PR #1321 ("Improve CLI command line parser") set out to relocate this method
from Main into CommandCommon as part of centralizing CLI parameter
handling. It was a long-lived branch: started June 2025, merged July 2026.
In the interim, PR #1715 (merged October 2025, "refactor(scripting):
structured features with runner and ui packages") replaced the old
ScriptRunner-based API with ScriptingModule / AbstractScriptRunner /
StandardScriptRunner, moving plugin-loading logic out of ScriptingWindow
into the new ScriptingModule.

When #1321 was finally merged into master and its conflicts against the
post-#1715 codebase were resolved, the relocated method was adapted to
reflectively call ScriptingModule.executeConsoleScript(...) instead of the
old direct API — but no equivalent entry point was ever added to
ScriptingModule (or the new runner classes) to receive that call. This
reconciliation gap was missed during conflict resolution.

Affected versions: master (6.2 development) only. Confirmed NOT present in
releases/6.1 / the released 6.1.1, which still carries the original
Main.java implementation using the old ScriptRunner-based API directly.

Impact: Silent failure, not a crash. Anyone relying on CLI console-mode with
a PROJECT_CHANGE script hook (--script) gets no error and no script
execution, on 6.2 development builds.

Suggested fix direction: Not decided here — left to implementation review.
Two directions worth considering:
(a) Add a static entry point on ScriptingModule matching the reflected
signature (executeConsoleScript(PROJECT_CHANGE_TYPE, File)),
delegating internally to AbstractScriptRunner.getActiveRunner() /
a to-be-added ConsoleScriptRunner. Minimal change, keeps
CommandCommon's existing reflective-call structure.
(b) HaveCommandCommon call the runner classes directly, dropping the
reflection layer that used to target the old ScriptRunner API and
was carried over by habit during the #1321/#1715 conflict
resolution, rather than for an active design reason.
Either way, whoever picks this up should port the binding setup from the
old Main.java implementation (ConsoleBindings mapped to
ScriptRunner.VAR_CONSOLE / VAR_GLOSSARY / VAR_EDITOR) to the equivalent
concept in the new runner API, since that binding setup was lost along with
the direct call.

Repro: Run OmegaT (master build) in console mode with a project-change
script configured; observe the swallowed NoSuchMethodException in the log
and the script not executing.

Discussion


Log in to post a comment.