Repository navigation
fix: treat empty port and app id environment variables as unset - #957
Open
rida-ghreizy wants to merge 1 commit into
Open
rida-ghreizy wants to merge 1 commit into
rida-ghreizy wants to merge 1 commit into
Conversation
APP_ID, DAPR_HTTP_PORT, DAPR_GRPC_PORT and APP_PORT were read with ??, so an empty variable (common in .env and docker-compose files) gave an empty port or app id instead of the default. Use || like the token and endpoint settings, and add tests. Signed-off-by: rida <ghreizyrida1@gmail.com>
This branch has not been deployed
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
Settings(src/utils/Settings.util.ts) reads the sidecar and app settings from the environment.DAPR_API_TOKEN,DAPR_HTTP_ENDPOINTandDAPR_GRPC_ENDPOINTuse||, so an empty variable falls back to the default.APP_ID,DAPR_HTTP_PORT,DAPR_GRPC_PORTandAPP_PORTuse??, so an empty variable is used as is.Empty variables are common:
DAPR_HTTP_PORT=in a.envfile, or- DAPR_HTTP_PORT=${DAPR_HTTP_PORT}in docker-compose when the host variable isn't set. With??:""DAPR_HTTP_PORT"", so the HTTP client builds127.0.0.1:without a port3500DAPR_GRPC_PORT""50001APP_PORT"", so the server listens on an empty port3000/50000APP_ID""my-dapr-appThis PR switches these four getters to
||, like the token and endpoint getters. A non-empty value is still used unchanged.Issue reference
No issue was filed; the problem is described above.
Checklist
test/unit/utils/Settings.util.test.tshas new cases that set the four variables to""(and restore them afterwards) and check the defaults, plus one case showing that a set value still wins. Without the change, 3 of them fail. With it, all 8 tests in the file pass. ESLint and Prettier are clean.