fix(activity:list): handle null result on in-progress activities#59
Merged
miguelsanchez-upsun merged 2 commits intomainfrom Apr 29, 2026
Merged
fix(activity:list): handle null result on in-progress activities#59miguelsanchez-upsun merged 2 commits intomainfrom
miguelsanchez-upsun merged 2 commits intomainfrom
Conversation
ActivityMonitor::formatResult() crashed with a TypeError when invoked on an activity whose result property was null (i.e. not yet finished). Coerce a missing result to an empty string before looking it up in the result-name map, so the function can always return a string. The bug surfaced after the change in formatResult's signature to take an Activity object rather than a string result, in legacy-cli #1572. Add a unit test for ActivityMonitor::formatResult covering success, failure, null/in-progress, and the failed-command override path. Add a PHPStan stub for Platformsh\Client\Model\Activity that marks result, completed_at and started_at as nullable. The upstream docblock declares them as non-null strings, which is why static analysis did not catch this. Running PHPStan at level 8 with the stub in place would have flagged the original bug. Closes #57 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime TypeError in ActivityMonitor::formatResult() when formatting in-progress activities whose result is null, aligning activity:list output with prior behavior (empty result column) and improving static analysis coverage via a local PHPStan stub.
Changes:
- Coerce a
nullactivity result to''before doing the result-name lookup. - Add PHPUnit coverage for success, failure, in-progress/null-result, and failed-command override paths.
- Configure PHPStan to load a local stub for
Platformsh\Client\Model\Activitywith nullable timestamp/result properties.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
legacy/src/Service/ActivityMonitor.php |
Prevents formatResult() from returning null by normalizing a null result to an empty string. |
legacy/tests/Service/ActivityMonitorTest.php |
Adds unit tests covering the fixed null-result/in-progress behavior and command failure overrides. |
legacy/phpstan.neon |
Registers the local Activity stub file for PHPStan analysis. |
legacy/phpstan-stubs/Activity.stub |
Documents nullable Activity model properties for more accurate static analysis. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address PR review feedback: - Set 'result' => null explicitly in the null-result test fixtures so the intent is unambiguous and not reliant on Activity model defaults. - Bring the PHPStan stub in line with Upsun's OpenAPI spec: mark created_at, updated_at, description and text as nullable; add cancelled_at, expires_at, integration and timings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
miguelsanchez-upsun
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #57.
ActivityMonitor::formatResult()threw aTypeErrorwhen invoked on an activity whoseresultwasnull(i.e. still in progress). The bug surfaced after upstream legacy-cli #1572 changed the signature to take anActivityobject instead of thestringresult and started reading$activity->resultinternally.The fix coerces a missing result to an empty string before the result-name lookup so the function always returns a string. An empty
resultcolumn inactivity:listfor in-progress activities matches the column's prior behavior.Changes
legacy/src/Service/ActivityMonitor.php- guard against null$activity->result.legacy/tests/Service/ActivityMonitorTest.php- new unit tests covering success, failure, null/in-progress, and failed-command-override paths.legacy/phpstan-stubs/Activity.stub+legacy/phpstan.neon- local PHPStan stub that marksresult,completed_atandstarted_atas?string. The upstream client docblock has them as non-nullstring, which is why PHPStan did not catch this. With the stub in place, running PHPStan at level 8 flags the original bug (and the equivalent fix passes); the project still runs at level 7 by default.