Fix mr:logs 404 by reading jobs and traces from the issue fork - #383
Merged
Merged
Conversation
Merge request pipelines on drupal.org run on the issue fork, not the target project. mr:logs passed the target project id to the jobs and trace endpoints, which answer 404 for every merge request. Fixes #378 (part 1) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…race is denied The API trace endpoint answers 401 without a GitLab token, and the CLI runs without one for most users. The catch block turned that into "(trace unavailable)" for every failed job. The job's web URL plus /raw serves the same log anonymously, so the action falls back to it. Fixes #378 (part 2) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ob log excerpts Raw GitLab job logs prefix every line with a timestamp and stream flag, wrap text in ANSI color codes, and carry section_start/section_end markers. The excerpt in mr:logs is read by people and agents, so it drops all three. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Fixes #378.
mr:logsfailed with a 404 on every drupal.org merge request, and after that was fixed it printed(trace unavailable)for every failed job when run without a GitLab token.What changed
$pipeline->project_id), which is the issue fork. Only the pipelines call belongs on the target project.<job web_url>/rawinstead. That endpoint serves the same log anonymously. Guzzle follows the redirect to object storage and drops theAuthorizationheader across origins.JobLog::clean(): runner timestamp prefixes, ANSI color codes, andsection_start/section_endmarkers are removed so the last 100 lines read like terminal output.Each change is its own commit.
Testing
Unit tests pin the jobs and trace calls to the pipeline's project id, cover the raw-log fallback, the double-failure case, and the log cleaner against real runner output.
Live, without a token:
Prints the failing
phpunitandphpstanjob excerpts from pipeline 947467 onissue/poll-3620831.🤖 Generated with Claude Code