Skip to content

fix: source notification-engine socket host from config, not a literal - #199

Open
princegupta1131 wants to merge 1 commit into
masterfrom
feat-sonarqube-integration-v2
Open

princegupta1131 wants to merge 1 commit into
masterfrom
feat-sonarqube-integration-v2

Conversation

@princegupta1131

Copy link
Copy Markdown

The previous commit hoisted 'http://notification-engine:3013' into a named constant, which moved the line without clearing Sonar's S5332 hotspot. The rule ignores localhost as non-routable and reports real hostnames: env.ts holds 42 http:// literals and this was the only one flagged.

The routable hostname now comes from the env var or the untracked env.local-defaults.json, matching how every other internal address in this file is already sourced. No routable http:// literal remains in env.ts.

The fallback stays a real value rather than undefined because server.ts passes it to ClientSocket(), and ClientSocket(undefined) silently connects to the process origin instead of failing - a refused connection to localhost is easier to diagnose than a silent misroute.

Reusing localhost:3013 made the literal appear three times, which tripped the duplicate-literal rule, so NETWORK_HUB_SERVICE_BACKEND and NOTIFICATION_ENGINE_API_BASE now share DEFAULT_LOCALHOST_3013 alongside DEFAULT_LOCALHOST_7001. Both resolve to the same values as before.

Behaviour change limited to one case: with no env var and no local defaults file, the socket URL is now http://localhost:3013 instead of the hard-coded cluster hostname. The tracked env-file never set this var, so no deployed environment should be in that state - and one that is now fails visibly instead of connecting by accident of a hard-coded host. CHANGE 50 updated with the three-scenario resolution table.

tsc, lint and build clean. Full Jest suite passes (224 suites, 3693 tests).

The previous commit hoisted 'http://notification-engine:3013' into a named
constant, which moved the line without clearing Sonar's S5332 hotspot. The
rule ignores localhost as non-routable and reports real hostnames: env.ts
holds 42 http:// literals and this was the only one flagged.

The routable hostname now comes from the env var or the untracked
env.local-defaults.json, matching how every other internal address in this
file is already sourced. No routable http:// literal remains in env.ts.

The fallback stays a real value rather than undefined because server.ts
passes it to ClientSocket(), and ClientSocket(undefined) silently connects
to the process origin instead of failing - a refused connection to localhost
is easier to diagnose than a silent misroute.

Reusing localhost:3013 made the literal appear three times, which tripped
the duplicate-literal rule, so NETWORK_HUB_SERVICE_BACKEND and
NOTIFICATION_ENGINE_API_BASE now share DEFAULT_LOCALHOST_3013 alongside
DEFAULT_LOCALHOST_7001. Both resolve to the same values as before.

Behaviour change limited to one case: with no env var and no local defaults
file, the socket URL is now http://localhost:3013 instead of the hard-coded
cluster hostname. The tracked env-file never set this var, so no deployed
environment should be in that state - and one that is now fails visibly
instead of connecting by accident of a hard-coded host. CHANGE 50 updated
with the three-scenario resolution table.

tsc, lint and build clean. Full Jest suite passes (224 suites, 3693 tests).

This branch has not been deployed

No deployments
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.

1 participant