Skip to content

feat: send spark error output to STDERR - #10598

Open
paulbalandan wants to merge 1 commit into
codeigniter4:4.8from
paulbalandan:cli-errors-to-stderr
Open

paulbalandan wants to merge 1 commit into
codeigniter4:4.8from
paulbalandan:cli-errors-to-stderr

Conversation

@paulbalandan

Copy link
Copy Markdown
Member

Description

Uncaught exceptions in spark, and errors shown with BaseCommand::showError() or AbstractCommand::renderThrowable() (as migrate and db:seed do), are now printed to STDERR instead of STDOUT, so they no longer mix with output piped to another program or captured by a script. The exit code is unchanged. This also prepares for a --quiet flag, which can then silence STDOUT without hiding errors.

The redirect happens in the exception handler rather than in the CLI error views. The views are copied into every app, so editing them would only reach new projects. Color support is checked against STDERR while redirecting, so 2> err.log does not collect ANSI codes when STDOUT is a terminal.

Scripts that redirect only STDOUT to a log file will no longer capture errors there. The upgrading guide covers this.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@carson-codeigniter4 carson-codeigniter4 Bot added the 4.8 PRs that target the `4.8` branch. label Oct 5, 2026
@paulbalandan
paulbalandan requested a balanced review from Copilot October 5, 2026 14:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

HTTP command error rendering, STDOUT newline preservation, and test-state cleanup need correction.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity

Open (3)
What changed in this PR

Routes Spark exception output to STDERR, keeping errors separate from piped STDOUT.

Changes:

  • Adds scoped redirection with STDERR-aware color detection.
  • Adds error-stream tests.
  • Documents behavior and logging migration.

Base branch was not supplied; develop compatibility policy was assumed. Validation was limited to source inspection; automated checks remain with CI.

File Description
user_guide_src/​source/​installation/​upgrade_480.rst Explains logging migration.
user_guide_src/​source/​cli/​cli_modern_commands.rst Documents STDERR rendering.
user_guide_src/​source/​cli/​cli_commands.rst Documents STDERR error output.
user_guide_src/​source/​changelogs/​v4.8.0.rst Records the behavior change.
tests/​system/​Debug/​ExceptionHandlerTest.php Checks exception output routing.
tests/​system/​CLI/​CLITest.php Tests redirection and colors.
tests/​system/​CLI/​BaseCommandTest.php Checks STDERR error rendering.
tests/​system/​CLI/​AbstractCommandTest.php Checks STDERR throwable rendering.
system/​Debug/​ExceptionHandler.php Redirects CLI exception rendering.
system/​CLI/​CLI.php Adds scoped stream redirection.
system/​CLI/​BaseCommand.php Redirects command error views.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread system/CLI/CLI.php
Comment thread system/CLI/CLI.php
Comment thread tests/system/CLI/CLITest.php
@paulbalandan
paulbalandan force-pushed the cli-errors-to-stderr branch 2 times, most recently from 2c1af2c to 44d1e6f Compare October 6, 2026 07:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants