Skip to content

fix: expose stderr and returncode from _run_stream via _last_stream_r… - #17

Open
uchime1234 wants to merge 1 commit into
TerraformInDepth:mainfrom
uchime1234:fix/stderr-capture-stream
Open

uchime1234 wants to merge 1 commit into
TerraformInDepth:mainfrom
uchime1234:fix/stderr-capture-stream

Conversation

@uchime1234

@uchime1234 uchime1234 commented Sep 15, 2026 •

Copy link
Copy Markdown

Summary

Stores a CommandResults instance on self._last_stream_result after _run_stream finishes, mirroring the existing pattern in _run.

Problem

Closes #11 — _run_stream captured stderr and returncode via subprocess.PIPE but silently discarded them, making terraform diagnostics unavailable to callers and subclasses (e.g. Celery workers that need to log TF_LOG output).

Changes

  • Initialized self._last_stream_result = None in __init__.
  • Populated self._last_stream_result with a CommandResults in _run_stream.
  • Updated the Tofu class docstring to document the new attribute.
  • Added tests/test_stream_results.py covering plan, apply, error-module, and repeat-run cases.

Testing

  • python -m pytest --cov=./tofupy --cov-report=term-missing tests
  • python -m ruff check
  • python -m ruff format . --check
  • python -m mypy tofupy
saving tests

All pass locally on Windows with OpenTofu 1.9.0.

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.

No way to capture stderr

1 participant