Drop the empty-string fallback on the Pro API key#108
Merged
Conversation
The pro-tier branch of COINGECKO_CLIENT sent \`'x-cg-pro-api-key': CONFIG.coingeckoApiKey ?? ''\`. The bootstrap check at the top of the module already guarantees one of the two env vars is set, so the only way this branch ran with an empty key was a misconfiguration that escaped the bootstrap. The empty header would then turn into an upstream 401 that looks like a CoinGecko outage instead of the local configuration problem it really is. Explicit throw + plain string assignment removes the silent fallback and surfaces the misconfiguration where it actually happens.
COINGECKO_API_KEY is no longer read by this service. The proxy stack holds the upstream key. COINGECKO_CLIENT is now a one-liner that always hits the proxy and the bootstrap refuses to start without COINGECKO_BASE_URL. No more two-branch logic, no more dead code.
The api can now also be pointed at pro-api.coingecko.com directly by setting COINGECKO_API_KEY alongside COINGECKO_BASE_URL — the key is attached as the x-cg-pro-api-key header on every request when set, no two-branch logic, no fallback. In the DFX setup COINGECKO_API_KEY stays unset because the proxy injects its own key. README documents the pattern and links the proxy reference implementation at github.com/DFXswiss/pricing-proxy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Follow-up to #106. The pro-tier branch of `COINGECKO_CLIENT` carried `'x-cg-pro-api-key': CONFIG.coingeckoApiKey ?? ''`. The bootstrap check guarantees one of the two env vars is set, so an empty key would only reach this branch through a misconfiguration that escaped the bootstrap. The empty header then turns into an upstream 401 that looks like a CoinGecko outage instead of the local config problem it really is.
Test plan