Skip to content

Handle error logs in environment:logs - #310

Open
joetannenbaum wants to merge 1 commit into
mainfrom
api-sync/environment-logs
Open

joetannenbaum wants to merge 1 commit into
mainfrom
api-sync/environment-logs

Conversation

@joetannenbaum

Copy link
Copy Markdown
Collaborator

Fixes environment:logs failing on the error log type the current API spec adds.

Findings

Field Spec CLI before
NormalizedLogResource.type (GET /environments/{environment}/logs) access, application, exception, error, system. error is new. LogType had no error case, so casting the page threw CannotCastEnum and environment:logs (including --json and --live) failed whenever an error log was in the window.
NormalizedLogResource.data New error shape: file, trace, channel, context, extra. Exception data adds context and extra. getExceptionData() dropped context and extra; there was no accessor for error data. --json passes data through as-is, so it was only the typed accessors that were behind.

Changes

  • LogType::ERROR, colored red like EXCEPTION.
  • EnvironmentLog::isErrorLog() and getErrorData(); getExceptionData() now includes context and extra. __toString() appends the file for an error log.
  • The log renderer shows an error log's message with its channel and file underneath.

Tests

New case in tests/Feature/EnvironmentLogsTest.php: a page with an error and an exception entry comes back through --json with its type and data, and the DTO accessors read the new fields. It fails on main with CannotCastEnum. Full suite (PromptFallbackTest skipped locally), RepoConfigTest without a token, PHPStan and Pint all pass.

No demo: no prompt changed, only how an error log line is labeled.


Generated by Claude Code

The API now returns logs with type `error`, which LogType could not
cast, so environment:logs failed as soon as one was in the window.
Exception logs also carry `context` and `extra` now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T1Sq4XqCCCt7YvvQ3usB6a
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.

2 participants