<#10372 bug: meltano run console output hides bloc...
# meltano-repo-activity
g
#10372 bug: meltano run console output hides block failure reason ("Block run completed" with no error) Issue created by visch (Ai Generated issue): Not sure how you all feel about these, but it does a much better job than I will giving all the details Meltano Version 4.4.0 (also present on
main
) Python Version 3.14 Bug scope CLI (options, error messages, logging, etc.) Operating System Linux Description When a block in
meltano run
fails, the default console output doesn't say why:
Copy code
[error    ] meltano      Block run completed
[info     ] meltano      Run completed
The exit code is 1, but the output gives no reason.
meltano invoke
on the same command shows the error. The failure reason is attached to the log event.
cli/run.py
logs it as structured keys: logger.error( "Block run completed", set_number=idx, block_type=blk_name, success=False, err=err.args[0] if err.args else err.class.name, exit_codes=err.exitcodes, duration_seconds=round(block_duration, 3), ) But
MeltanoConsoleRenderer.__call__
(
core/logging/renderers.py
) drops every key that isn't in
default_keys
, unless
all_keys
or
include_keys
is set: elif not self._all_keys: event_dict = {k: v for k, v in event_dict.items() if k in self.default_keys}
err
and
exit_codes
aren't in
default_keys
, so the reason is dropped.
status
on the final "Run completed" event is dropped the same way, so a failed run and a successful one look alike apart from the level. Steps to reproduce # meltano.yml version: 1 default_environment: dev environments: - name: dev plugins: utilities: - name: my-utility namespace: my_utility executable: echo $ meltano run my-utility:hello [error ] meltano Block run completed [info ] meltano Run completed $ echo $? 1 $ meltano invoke my-utility:hello UnknownCommandError: Command 'hello' could not be found. Utility 'my-utility' does not define any commands. The information is there with `--log-format=json`: {"block_type": "InvokerCommand", "success": false, "err": "Cannot start plugin: Command 'hello' could not be found. Utility 'my-utility' does not define any commands.", "exit_codes": {}, "event": "Block run completed", "level": "error", ...} Workaround A project
logging.yaml
that passes
include_keys
to the console formatter shows the reason: version: 1 disable_existing_loggers: false formatters: console: (): meltano.core.logging.console_log_formatter colors: true include_keys: [err, exit_codes, status] handlers: console: class: logging.StreamHandler level: INFO formatter: console stream: ext://sys.stderr root: level: INFO handlers: [console]
Copy code
[error    ] meltano      Block run completed            err="Cannot start plugin: Command 'hello' could not be found. Utility 'my-utility' does not define any commands." exit_codes={}
[info     ] meltano      Run completed                  status=failure
A custom
logging.yaml
replaces the default logging setup completely, so
--log-level
and
--log-format
stop working. Users shouldn't need one to find out why a run failed. Expected behavior The default console output of a failed
meltano run
should include the failure reason. Suggested fix Add
err
,
exit_codes
and
status
to
MeltanoConsoleRenderer.default_keys
. This is the same change the workaround makes, applied by default. The trade-off is that successful blocks also print
err=None
. If that's unwanted,
run.py
could leave out
err
on success, or put the reason in the event text on failure, e.g.
"Block run failed: {err}"
. Related: #7372 (closed as stale). It covers
meltano run
output being harder to understand than
meltano invoke
. meltano/meltano