fix(activity:log): drop stray query params from log stream URL#56
Merged
miguelsanchez-upsun merged 2 commits intomainfrom Apr 29, 2026
Merged
fix(activity:log): drop stray query params from log stream URL#56miguelsanchez-upsun merged 2 commits intomainfrom
miguelsanchez-upsun merged 2 commits intomainfrom
Conversation
The activity log link, resolved via Platformsh\Client\Model\Activity::getLink('log'),
inherits the query string of the base URL the activity was loaded with. When the
activity collection is fetched with a 'count' parameter, that parameter is carried
into the absolute log URL by ApiResourceBase::makeAbsoluteUrl(), which only swaps
the path. The log endpoint rejects 'count' with HTTP 400, producing repeated fopen
warnings in verbose mode and breaking the streaming retry loop.
Strip the query string before opening the stream. The non-streaming readLog() path
(Activity::fetchLog -> Guzzle 'query' option) already replaces the query string and
is unaffected.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Operator precedence made (int) $interval * 1000000 evaluate as ((int) 0.5) * 1000000, so the retry loop in getLogStream() called usleep(0) and spun as fast as PHP could re-issue fopen on a failing log endpoint. Wrap the multiplication in parentheses so the intended 500000 microsecond delay is applied. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes log streaming for activity:log (and other waited activities) in the legacy CLI by ensuring the log stream URL does not include inherited query parameters that the log endpoint rejects, and by correcting a retry-loop sleep timing bug that caused rapid spinning on failure.
Changes:
- Strip any query string from the activity log stream URL before opening the stream (avoids HTTP 400 due to inherited params like
count). - Fix operator precedence in the retry loop so
usleep()waits the intended 0.5 seconds between retries.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
When
activity:log(or any waited activity) opens its log stream, the URL itfopens comes fromPlatformsh\Client\Model\Activity::getLink('log'). The client library'sApiResourceBase::makeAbsoluteUrl()resolves the relative log link against the activity's base URL by swapping in the relative target's path, but keeps the base's query string. So when the activity was loaded via/projects/<id>/activities?count=1(e.g.--all, or any default-activity selection), the resulting log URL is.../activities/<id>/log?count=1.The log endpoint rejects
countwith HTTP 400. Without verbose mode thefopenwarning is hidden, but the streaming retry loop inActivityMonitor::getLogStream()still spins until its 2-minute timeout. With-vv, the user sees a flood ofWarning: fopen(...): Failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request.This PR works around the issue in the legacy CLI by stripping the query string from the log URL before opening the stream. The non-streaming
Activity::readLog()path goes through Guzzle with thequeryrequest option, which already replaces the URL's query string, and is unaffected.A second commit fixes a long-standing operator-precedence bug in the same retry loop:
(int) $interval * 1000000evaluated as((int) 0.5) * 1000000 = 0, sousleep(0)was called instead of the intended 0.5-second sleep, causing the loop to spin as fast as PHP could re-issuefopenon the failing endpoint. Wrapping the multiplication in parentheses restores the intended delay.The underlying link-resolution bug should also be fixed upstream in
platformsh-client-php; that's tracked separately.