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

Improve error handling for missing dependency versions for github actions #11144

Merged
merged 4 commits into from
Dec 19, 2024

Conversation

robaiken
Copy link
Contributor

@robaiken robaiken commented Dec 17, 2024

What are you trying to accomplish?

Improves error handling by raising a clear UnresolvableVersionError error when dependencies lack version constraints, rather than failing with a generic Sorbet error. This helps users understand exactly which dependencies are failing.

Anything you want to highlight for special attention from reviewers?

Chose to fail fast during parsing rather than proceeding with dependencies that are not semver. This provides clearer feedback and prevents Sorbet from raising confusing type errors later in the update process.

How will you know you've accomplished your goal?

When the parse method correctly identifies dependencies without versions and raises an UnresolvableVersionError rather than a Sorbet issue message.

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.

@robaiken robaiken self-assigned this Dec 17, 2024
@robaiken robaiken requested a review from a team as a code owner December 17, 2024 18:36
@github-actions github-actions bot added the L: github:actions GitHub Actions label Dec 17, 2024
@robaiken robaiken marked this pull request as draft December 17, 2024 18:37
@@ -35,6 +35,9 @@ def parse
dependency_set += workfile_file_dependencies(file)
end

dependencies_without_version = dependency_set.dependencies.select { |dep| dep.version.nil? }
raise UpdateNotPossible, dependencies_without_version.map(&:name) unless dependencies_without_version.empty?
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a more descriptive error message?

UpdateNotPossible is overloaded and opaque to our users.

Copy link
Member

Choose a reason for hiding this comment

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

Tagging @kbukum1 since he has a list of some of our common errors that already have paved paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created a new error class to handle this specific case

@robaiken robaiken force-pushed the robaiken/show-warning-if-no-version-found branch from c6dcd8e to 36a9651 Compare December 17, 2024 19:01
@robaiken robaiken marked this pull request as ready for review December 17, 2024 19:03
@robaiken robaiken force-pushed the robaiken/show-warning-if-no-version-found branch from 36a9651 to a7f6a67 Compare December 17, 2024 19:03

sig { returns(T::Array[String]) }
attr_reader :dependencies

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding a new class; I think you'll have to make some changes on the API end too to get this error to sho up. @kbukum1 , can you share some sample past PRs?

@robaiken robaiken force-pushed the robaiken/show-warning-if-no-version-found branch from a7f6a67 to 085771a Compare December 18, 2024 11:22
Copy link
Contributor

@kbukum1 kbukum1 left a comment

Choose a reason for hiding this comment

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

LGTM

@robaiken robaiken force-pushed the robaiken/show-warning-if-no-version-found branch from 4ce06e6 to 56728db Compare December 18, 2024 17:29
@robaiken robaiken force-pushed the robaiken/show-warning-if-no-version-found branch from 56728db to ae52141 Compare December 19, 2024 11:05
@robaiken robaiken merged commit 6c7a3b7 into main Dec 19, 2024
127 checks passed
@robaiken robaiken deleted the robaiken/show-warning-if-no-version-found branch December 19, 2024 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: github:actions GitHub Actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants