Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle php version mismatch error. #11703

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thavaahariharangit
Copy link
Contributor

@thavaahariharangit thavaahariharangit commented Feb 28, 2025

What are you trying to accomplish?

I am trying to resolve an issue in this workflow: GitHub Actions Run.

Issue:

Currently, the workflow encounters an error but still shows as successful. And shows below logs: (It is not user friendly)

updater | 2025/02/27 15:41:31 ERROR <job_971685177> Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Root composer.json requires league/csv >= 9.7, == 9.21.0 -> satisfiable by league/csv[9.21.0].
    - league/csv 9.21.0 requires php ^8.1.2 -> your php version (8.1; overridden via config.platform, actual: 8.2.27) does not satisfy that requirement.
updater | 2025/02/27 15:41:31 ERROR <job_971685[177](https://github.com/dsp-testing/league-csv-sample/actions/runs/13570217169/job/37933001194#step:3:179)> /home/dependabot/common/lib/dependabot/shared_helpers.rb:200:in `run_helper_subprocess'
2025/02/27 15:41:31 ERROR <job_971685177> /home/dependabot/dependabot-updater/vendor/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/call_validation.rb:270:in `bind_call'
updater | 2025/02/27 15:41:31 ERROR <job_971685177> /home/dependabot/dependabot-updater/vendor/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/call_validation.rb:270:in `validate_call'
2025/02/27 15:41:31 ERROR <job_971685177> /home/dependabot/dependabot-updater/vendor/ruby/3.3.0/gems/sorbet-runtime-0.5.11577/lib/types/private/methods/_methods.rb:277:in `block in _on_method_added'
2025/02/27 15:41:31 ERROR <job_971685177> /home/dependabot/composer/lib/dependabot/composer/update_checker/version_resolver.rb:144:in `block in run_update_checker'
2025/02/27 15:41:31 ERROR <job_971685177> /home/dependabot/common/lib/dependabot/shared_helpers.rb:299:in `with_git_configured'

Solution Provided

  1. Improved Error Messaging
  • The logs will no longer display the full stack trace.
  • Instead, they will show a clear and structured error message, such as:
{
  "data": {
    "error-type": "php_version_mismatch_error",
    "error-details": {
      "message": "PHP version mismatch: Your requirements could not be resolved to an installable set of packages.\n  
      Problem 1\n  
      - Root composer.json requires league/csv >= 9.7, == 9.22.0 -> satisfiable by league/csv[9.22.0].\n  
      - league/csv 9.22.0 requires php ^8.1.2 -> your php version (8.1; overridden via config.platform, actual: 8.2.27) does not satisfy that requirement."
    }
  },
  "type": "record_update_job_error"
}
  1. Failing the Workflow on Errors
  • The workflow will now properly fail when an error occurs.
  • The error summary will be structured as:
updater | Dependabot encountered '1' error(s) during execution, please check the logs for more details.
updater | +-----------------------------------------+
updater | |      Dependencies failed to update      |
updater | +------------+----------------------------+
updater | | league/csv | php_version_mismatch_error |
updater | +------------+----------------------------+

This ensures that errors are more readable and that the workflow status correctly reflects failure when dependencies cannot be updated.

Anything you want to highlight for special attention from reviewers?

N/A

How will you know you've accomplished your goal?

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@thavaahariharangit thavaahariharangit requested a review from a team as a code owner February 28, 2025 15:56
@github-actions github-actions bot added the L: php:composer Issues and code for Composer label Feb 28, 2025
@thavaahariharangit thavaahariharangit self-assigned this Feb 28, 2025
@@ -114,9 +114,12 @@ def self.fetcher_error_details(error)
"error-type": "illformed_requirement",
"error-detail": { message: error.message }
}
when Dependabot::PhpVersionMismatchError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can reuse some ToolVersion or existing error; tagging @kbukum1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: php:composer Issues and code for Composer
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants