Skip to content

improve error messages that came up when trying to start a modal agent with a different repo/configuration#904

Open
evgunter wants to merge 8 commits intomainfrom
mng/modal-debugging
Open

improve error messages that came up when trying to start a modal agent with a different repo/configuration#904
evgunter wants to merge 8 commits intomainfrom
mng/modal-debugging

Conversation

@evgunter
Copy link
Contributor

@evgunter evgunter commented Mar 18, 2026

Summary

Multiple layers of error reporting were silently discarding diagnostic information, making subprocess failures impossible to debug.

host.py -- git push/clone errors only showed e.stderr

ProcessError.__str__() already includes command, returncode, stdout, and stderr. The error handlers were manually extracting just e.stderr, losing everything else. Changed to str(e). For the CommandResult path (remote push), stderr and stdout are now combined.

subprocess_utils.py -- ProcessSetupError swallowed the OS error

When subprocess.Popen raises OSError (e.g. binary not found, bad cwd), two things went wrong:

  1. The original error message was discarded (empty stderr="")
  2. is_output_already_logged was passed through as True from the caller (since trace output is always enabled), suppressing the output section even when nothing was ever logged

Fixed by including str(e) in stderr and hardcoding is_output_already_logged=False (the process never started, so nothing was streamed).

loader.py -- better error when backend plugin is missing

When a provider config references an unknown backend, the error message now distinguishes between: the specific plugin being disabled, some other plugin being disabled, or no plugins disabled (suggesting the package isn't installed).

Context

Found when debugging a Modal agent creation failure where git push --mirror failed in 0.004s with "Failed to push git repo:" and nothing after the colon. After fixing the error reporting, the real error was revealed: [Errno 2] No such file or directory: git -- the subprocess PATH was stripped before mng started (a uv tool environment issue, not an mng bug).

Test plan

  • 3034 mng unit/integration tests pass
  • 148 concurrency_group tests pass
  • Confirmed fixes surface real errors in live Modal agent creation

evgunter and others added 8 commits March 17, 2026 22:00
The error reporting for git push --mirror, git clone --mirror, and
remote git push only included e.stderr, which can be empty when git
writes errors to stdout. This made failures like the 0.004s local
git push failure impossible to diagnose ("Failed to push git repo:"
with nothing after the colon).

Now all three error paths include both stdout and stderr plus the
exit code via a shared _format_process_error_details helper.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ProcessError already formats a comprehensive message with command,
returncode, stdout, and stderr. No need for a custom helper.
When subprocess.Popen raises OSError (e.g. binary not found, bad cwd),
the error message was lost -- ProcessSetupError was created with empty
stderr, producing 'Command failed to start None' with no explanation.
Now includes str(e) so the actual OS error is visible.
The is_output_already_logged flag was being passed through from the
caller, but for setup errors the process never started so nothing
could have been logged. This caused stderr=str(e) to be silently
suppressed when trace_output was True (which is always the case
when running via ConcurrencyGroup).
The previous error "references unknown backend" gave no hint about the
cause. Now provides three specific messages: plugin is disabled, another
plugin might provide it, or the plugin package may not be installed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ing in the class

The previous fix hardcoded is_output_already_logged=False inside
ProcessSetupError, silently ignoring the parameter. This is too broad --
the real issue is that the one call site in subprocess_utils.py was
passing trace_output (which means "streaming was requested") even though
Popen failed before any output was streamed. Fix it at the source.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines -222 to +224
stderr="",
is_output_already_logged=trace_output,
stderr=str(e),
# Popen failed, so no output was ever streamed regardless of trace_output.
is_output_already_logged=False,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

suspicious

@evgunter evgunter changed the title Include stdout and exit code in git push error messages improve error messages that came up when trying to start a modal agent Mar 20, 2026
@evgunter evgunter changed the title improve error messages that came up when trying to start a modal agent improve error messages that came up when trying to start a modal agent with a different repo/configuration Mar 20, 2026
@evgunter evgunter marked this pull request as ready for review March 20, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant