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 HttpClient BaseAddress setting #125

Merged
merged 2 commits into from
Mar 19, 2024
Merged

Fix HttpClient BaseAddress setting #125

merged 2 commits into from
Mar 19, 2024

Conversation

thefrooh
Copy link

When executing azure-cost with default command accumulatedCost, I encountered the following error message: "This instance has already started one or more requests. Properties can only be modified before sending the first request."

The PR #122 added the ability to select CostApi and PriceApi base URL which seems to broke at least accumulatedCost command. This is caused by setting the BaseAddress property of a HttpClient that has already made a request before. The accumulatedCost command uses the same instance of ICostRetriever to make multiple HTTP requests, and when making the second call, the error above occurs.

To overcome this issue, the BaseAddress should be set for the HttpClient only if it differs from the default value, which will ideally not change throughout its lifecycle.

I also removed the hardcoded PriceApi address that is probably a leftover, and use the default or the one set through CLI args.

@thefrooh thefrooh requested a review from mivano as a code owner March 19, 2024 16:40
Copy link

welcome bot commented Mar 19, 2024

Thanks for opening this pull request!

@mivano
Copy link
Owner

mivano commented Mar 19, 2024

Ai, looks like I missed some things in the testing. Thanks for the PR!

@mivano mivano merged commit 526ada7 into mivano:main Mar 19, 2024
2 checks passed
Copy link

welcome bot commented Mar 19, 2024

Congrats on merging your first pull request!

@mivano
Copy link
Owner

mivano commented Mar 19, 2024

I pushed version 0.39 with this fix. Again thanks for your PR!

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.

None yet

2 participants