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

Fix an issue where the resty clients weren't initialized correctly #89

Merged
merged 2 commits into from
Jun 1, 2024

Conversation

moredatapls
Copy link
Contributor

@moredatapls moredatapls commented Apr 24, 2024

The restWithAuthentication function always only used c.restClient, even if a c.restClientVsrm was requested.

Fix it by passing pointers to the respective function.

Fixes #86

I tested the changes locally against our DevOps instance and I didn't see the 404 errors anymore

Copy link

sonarcloud bot commented Apr 24, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@moredatapls
Copy link
Contributor Author

Any chance that this can be reviewed and merged soon-ish @mblaschke? It would help us greatly :) Thank you for your efforts

Copy link

sonarcloud bot commented Jun 1, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@mblaschke mblaschke merged commit 4b44572 into webdevops:main Jun 1, 2024
3 checks passed
azure-devops-client/main.go Outdated Show resolved Hide resolved
.gitignore Show resolved Hide resolved
if *restClient == nil {
*restClient = c.restWithoutToken(domain)
func (c *AzureDevopsClient) restWithAuthentication(restClient *resty.Client, domain string) (*resty.Client, error) {
if restClient == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mblaschke I see that you removed the double pointer I added here. I added this on purpose: assigning a value to restClient here will not update c.restClient that gets passed into this function. To make this work, I added the double pointer, so that I can actually update the c.restClient field.

Therefore, the client will not get cached in the devops client object (c.restClient will always be nil), if restClient == nil statement will always evaluate to true, and the client will always get reinitialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting 404 in the release definitions API
2 participants