Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Fix GetSinglePersonalAccessTokenByID arg name #1954

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

theipster
Copy link
Contributor

@theipster theipster commented Jun 10, 2024

Calling the token ID user is extremely confusing...!

Relates to #1686.

Calling the token ID `user` is _extremely_ confusing...!
Copy link
Member

@svanharmelen svanharmelen left a comment

Choose a reason for hiding this comment

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

I can appreciate the user -> token change (makes sense), but I do not like to ignore error checking.

In my opinion you shoud always check errors, also in tests. So please revert those changes.

Updating the error message to make it more descriptive and applicable to the actual error is of course fine.

@theipster
Copy link
Contributor Author

@svanharmelen Thanks for the quick response! 🙂

In my opinion you shoud always check errors, also in tests. So please revert those changes.

Updating the error message to make it more descriptive and applicable to the actual error is of course fine.

I'm happy to update my PR, but can you please explain what the purpose is / what error you might expect to see in these specific lines of code, given that it's essentially calling a standard library function with fixed arguments (so the return value will always be fixed)? Error checking would make sense if the arguments were variable, but that's not the case here.

Also, the TestRotatePersonalAccessToken test doesn't have error checking either.

@svanharmelen
Copy link
Member

I'm not going to spent too much words on it, but I believe that you should always check all your errors everywhere. As soon as you start to reason about which error checks make sense and which do not, you'll be on a slippery slope just waiting for a missed error check to bites you in production when you least expect it.

Next to that it will set a precedent for other users or committers of this package or maybe even to people who are new at Go. I prefer to encourage them to get used to just always check all errors as in my opinion the Go language best practices also encourages you to do so.

If TestRotatePersonalAccessToken doesn't do error checking then that one slipped through unintentionally. So feel free to update that test instead in order to fix it and make everything consistent again.

@theipster theipster force-pushed the fix-personal-access-token-args branch from f07a2a4 to cc0188d Compare June 11, 2024 11:47
@theipster
Copy link
Contributor Author

@svanharmelen I've now removed the changes regarding the tests.

As a general best practice, I understand and agree with your intentions. However, in this particular case, I'm struggling to articulate what the error message should actually be (and PersonalAccessTokens.ListPersonalAccessTokens returned error:" is definitely not accurate because it has nothing to do with the ListPersonalAccessTokens function), so I'll leave it for somebody smarter than me to rename the error message.

Copy link
Member

@svanharmelen svanharmelen left a comment

Choose a reason for hiding this comment

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

Thanks @theipster 👍🏻

@svanharmelen svanharmelen merged commit a945941 into xanzy:main Jun 11, 2024
6 checks passed
@theipster theipster deleted the fix-personal-access-token-args branch June 11, 2024 14:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants