Skip to content

feat: add copyable error reports to detailed exception pages#10220

Open
memleakd wants to merge 1 commit into
codeigniter4:4.8from
memleakd:feat/copy-error-report
Open

feat: add copyable error reports to detailed exception pages#10220
memleakd wants to merge 1 commit into
codeigniter4:4.8from
memleakd:feat/copy-error-report

Conversation

@memleakd
Copy link
Copy Markdown
Contributor

Description

This PR proposes adding a Copy Details button to CodeIgniter’s detailed HTML exception page.

The goal is to make debugging information easier to share from the local development error page. Instead of manually gathering the relevant debugging information, users can copy a Markdown-formatted report with one click and paste it into an issue, discussion, chat, LLM or anywhere else they need.

Copy.Details.mp4

The copied report includes the most useful debugging context:

  • Exception type, status code, status text, and message
  • PHP, CodeIgniter, environment, SAPI, timestamp, and memory usage
  • Request method, path, safe URL without query string, and user agent
  • Source file location and nearby source lines
  • Previous exceptions, when available
  • Stack trace

The report intentionally avoids riskful or sensitive request data. It does NOT include headers, cookies, query strings, request body data, session data, route params, database queries, or trace arguments.

Implementation wise, the Markdown report is rendered by a small error_report.php partial used by the detailed HTML error view. The button uses the Clipboard API when available and falls back to a textarea-based copy path when needed.

Tests cover rendering the button, escaping the hidden report content, including previous exceptions, and omitting sensitive request data, trace arguments, and query strings from copied output.

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

Add a Copy Details action to detailed HTML exception pages.

- Render a copyable Markdown error report from the error view
- Include safe exception, environment, request, source, and stack trace context
- Omit sensitive request data, query strings, cookies, body data, and trace args
- Add tests for report rendering, escaping, previous exceptions, and privacy

Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
@github-actions github-actions Bot added the 4.8 PRs that target the `4.8` branch. label May 19, 2026
$reportTitle = $reportTitle === '' ? $title : explode("\n", $reportTitle, 2)[0];
$messageLines = str_contains($reportMessage, "\n");

$reportResponse = new Response();
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.

Suggested change
$reportResponse = new Response();
$reportResponse = service('response');

Response object can be redefined by custom

@patel-vansh
Copy link
Copy Markdown
Contributor

Really nice change. It will be really useful while debugging.

Just a thought. Maybe we could also supply which particular features are enabled/disabled. Like, CSRF enabled, CSP disabled, etc. so, in this way, we can debug more easily.

Also, we could also add route details too, like what is alias for this route, which controller method it corresponds to, which filters ran for these routes. And since this error page is only visible in dev environment and not in production, we can assume that revealing filter information or controller method can't be risky.

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