Skip to content

fix(cli): fix deco services CLI's stale duplicate of externalUrlOrNull - #5220

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/services-cli-ipv6-loopback-external-url-w1
Jul 24, 2026
Merged

fix(cli): fix deco services CLI's stale duplicate of externalUrlOrNull#5220
pedrofrxncx merged 1 commit into
mainfrom
fix/services-cli-ipv6-loopback-external-url-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Follow-up hardening on #5217 (fix(settings): treat bracketed IPv6 loopback DATABASE_URL/NATS_URL as local).

That PR fixed externalUrlOrNull in apps/api/src/settings/resolve-config.ts to strip brackets from URL#hostname before comparing against the bare loopback forms (localhost, 127.0.0.1, ::1). It missed that apps/api/src/cli/commands/services.ts kept its own private copy of the exact same function, used by deco services up/down.

Failure scenario: running deco services up with DATABASE_URL="postgres://[::1]:5432/postgres" or NATS_URL="nats://[::1]:4222"URL#hostname returns "[::1]" (brackets kept), which doesn't match the bare "::1" check, so the CLI's copy misclassifies a local loopback address as an external service. ensureServices then skips provisioning the local managed Postgres/NATS (skipPostgres/skipNats gate directly on this null-check, see apps/api/src/services/ensure-services.ts:1507-1508), leaving nothing listening at that address.

Fix: export the already-fixed, already-tested externalUrlOrNull from resolve-config.ts and import it in services.ts instead of keeping a second, drifted copy — net -12 lines, no behavior change to the already-correct path, only closes the gap in the duplicate.

Verify: bun test apps/api/src/settings/resolve-config.test.ts (58 pass, including the bracketed-IPv6 cases added by #5217, which now also exercise the code path services.ts delegates to) and cd apps/api && bunx tsc --noEmit (clean). No new test added — the fix removes the duplicate rather than adding parallel logic, so the existing resolve-config.test.ts coverage is now the only coverage needed for both call sites.

Ran locally: bun run fmt, targeted bunx tsc --noEmit in apps/api, and the single test file above. Full CI validates the rest.


Summary by cubic

Fixes the deco services CLI misclassifying bracketed IPv6 loopback URLs as external. Reuses the exported externalUrlOrNull from resolve-config.ts and removes the stale duplicate, so local Postgres/NATS are provisioned as expected.

Written for commit 6925643. Summary will update on new commits.

Review in cubic

The `deco services up/down` externalUrlOrNull had its own copy of the
external-host check, missing the bracketed-IPv6 fix landed in #5217 for
resolve-config.ts's copy. A bracketed IPv6 loopback DATABASE_URL/NATS_URL
(e.g. "postgres://[::1]:5432/postgres") kept the brackets in
`URL#hostname`, failed the bare "::1" comparison, and was wrongly treated
as external — skipping local Postgres/NATS provisioning.

Export the already-fixed, already-tested resolve-config.ts helper and
import it in services.ts instead of keeping a second copy.
@pedrofrxncx
pedrofrxncx merged commit f11f98a into main Jul 24, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/services-cli-ipv6-loopback-external-url-w1 branch July 24, 2026 19:21
decocms Bot pushed a commit that referenced this pull request Jul 24, 2026
PR: #5220 fix(cli): fix deco services CLI's stale duplicate of externalUrlOrNull
Bump type: patch

- decocms (apps/api/package.json): 4.125.2 -> 4.125.3

Deploy-Scope: server
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