Use environment variable for BASE_URL in pricesV2UsdAdapter#489
Open
blurpesec wants to merge 1 commit intoconsensys-vertical-apps:mainfrom
Open
Use environment variable for BASE_URL in pricesV2UsdAdapter#489blurpesec wants to merge 1 commit intoconsensys-vertical-apps:mainfrom
blurpesec wants to merge 1 commit intoconsensys-vertical-apps:mainfrom
Conversation
|
|
||
| export const USD = 'USD' | ||
| const BASE_URL = 'https://price-api.metafi.codefi.network' | ||
| const BASE_URL = process.env.PRICE_API ?? 'https://price-api.metafi.codefi.network' |
There was a problem hiding this comment.
Empty env var bypasses fallback due to nullish coalescing
Medium Severity
Using ?? (nullish coalescing) instead of || means that if PRICE_API is set to an empty string (which some CI/Docker environments do), the fallback URL won't activate. An empty BASE_URL will then cause new URL(...) on line 112 to throw a TypeError: Invalid URL, and since that call sits outside the try/catch block, the error propagates unhandled from getSpotPriceByAddress.
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.


Description
Pre-merge author checklist
update mecomments are removedtestCases.tsfile for every relevant method that has been implementedgetAddressfromethersSimplePoolAdaptergetPositionsis not overwritten and, if it is, it's clearly explained why in the PRunwrapis not overwritten and, if it is, it's clearly explained why in the PRIMetadataBuilderbuildMetadatamethod is implemented with the@CacheToFiledecoratorNote
Low Risk
Small, isolated configuration change; risk is limited to misconfiguration of the environment variable causing requests to target the wrong endpoint.
Overview
The
PricesV2UsdAdapternow reads the spot-price APIBASE_URLfromprocess.env.PRICE_API, falling back to the existinghttps://price-api.metafi.codefi.networkdefault when unset.Written by Cursor Bugbot for commit 6bf0c8c. This will update automatically on new commits. Configure here.