Fix #564: Improve error checking logic #667
Merged
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.
Describe what this PR does / why we need it
Improves the error handling and user notifications when the user does not want to use Projects v2 by default, i.e., when not setting the
default_to_projects_v2
config option or setting it tofalse
.In the current code users see an unexpected error message about missing
gh
token scopes in two different scenarios:default_to_projects_v2
and they do not have theread:project
or theproject
scopes in theirgh
tokenread:project
or theproject
scope in theirgh
token but have not set thedefault_to_projects_v2
or have set it tofalse
.In other words: They will always receive an error message if
default_to_projects_v2
is disabled.They should only recive an error message if they enable
default_to_projects_v2
and do not have one of the necessary scopes in their token.The PR changes the logic in the check such that it only checks for token scopes if the user actually enables
default_to_projects_v2
.I believe this change makes the "how to suppress the error" part in the corresponding section in the FAQ unnecessary, but I'm not sure. Please let me know if this assumption is correct, and I will update the README as part of this PR.
Does this pull request fix one issue?
Fixes #564
Describe how you did it
Changed a conditional checking both
default_to_projects_v2
and token set conditions (usingand
) to instead check fordefault_to_projects_v2
first. If that is not set totrue
then we don't need to check for scopes.Describe how to verify it
default_to_projects_v2
or set it tofalse
in the Octo config. Ensure that theproject
andread:project
scopes are not set. Load the plugin and confirm that no error message is shown.default_to_projects_v2
totrue
. Ensure that theproject
andread:project
scopes are not set. Load the plugin and confirm that an error message is shown.default_to_projects_v2
totrue
. Ensure that theproject
andread:project
scopes are set. Load the plugin and confirm that an error message is not shown.Special notes for reviews
Checklist