Skip to content

fix(cli): match Go's functions serve docker-down error, kong reload args, and secret name casing - #5976

Draft
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1984-functions-serve-parity-docker-down-error-kong-reload-args
Draft

fix(cli): match Go's functions serve docker-down error, kong reload args, and secret name casing#5976
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1984-functions-serve-parity-docker-down-error-kong-reload-args

Conversation

@Coly010

@Coly010 Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What changed

Three Go-parity fixes for functions serve in apps/cli/src/shared/functions/serve.ts, plus one minor watcher parity item and review follow-ups.

1. Docker-down error and ordering — removed the TS-only upfront docker precheck (failed to run docker. Docker Desktop is a prerequisite …). Go's restartEdgeRuntime has no such precheck (internal/functions/serve/serve.go:107-113): it loads config first, then asserts the local DB container, so a down Docker daemon surfaces as failed to inspect service: <connection error> with the Docker Desktop install hint on its own stderr line (internal/utils/misc.go:155-166 CmdSuggestion, rendered by cmd/root.go:300-303). assertLocalDbRunning now attaches that hint as an error suggestion when the daemon is unreachable, and the daemon-unreachable matcher (legacy-docker-suggest.ts) additionally recognizes socket permission-denied errors, which the pinned Docker SDK (v28.5.2, client/request.go:144-152) also classifies as connection failures. Ordering verified against Go: everything Go validates during config load before its DB assert (signing keys, jwt_secret, deno_versionpkg/config/config.go:1110-1172) already runs before the TS DB assert too.

2. Kong reload argsreloadKong now runs bare kong reload, matching Go (serve.go:129). The --nginx-conf /home/kong/custom_nginx.template argument belongs to start's Kong bring-up entrypoint (start.go:589-592), which persists the prefix configuration kong reload reuses — it was never part of Go's serve path, TLS-enabled stacks included.

3. [edge_runtime.secrets] name casing + filteringtoPlainEdgeRuntimeConfig now injects secret names verbatim (previously uppercased: my_secret reached the container as MY_SECRET) and only entries with a resolved non-empty value, mirroring Go's set.ListSecrets SHA256 > 0 gate (internal/secrets/set/set.go:48-52, pkg/config/secret.go:94-107): empty values and unresolved env(VAR) literals are skipped.

⚠️ Release-note worthy: a function written against the TS shell's uppercasing bug (config key my_secret, code reading Deno.env.get("MY_SECRET")) will now — correctly, matching the Go CLI — receive the key as my_secret.

Both shells / shared consumers

shared/functions/serve.ts is shared infrastructure. Fix 3's helper is also used by legacy start's edge-runtime bring-up — the verbatim/filtered semantics are Go-correct there too (Go start reaches the identical ListSecrets path via ServeFunctions, start.go:1104), and a start integration assertion now pins it. Fixes 1–2 are functions serve-only code paths; other commands' docker-down messages (legacy-docker-run.layer.ts etc.) are untouched. The widened daemon-unreachable matcher benefits all its consumers (serve, db bootstrap seam, image resolve/prepull) in the Go-correct direction. The next shell does not consume these paths (functions dev runs via @supabase/stack).

Minor watcher items (from the issue)

  • Fixed: the file-change line now prints Go's fsnotify op token — File change detected: <path> (WRITE|CREATE|REMOVE) — instead of always (update); the node fs.watch layer classifies rename events via an existence check. RENAME/CHMOD/OR-combined ops are unreachable under node's watcher (documented in-code).
  • Still open (deliberately): the SUPABASE_FUNCTIONS_WATCH_LIMIT cap/hint (watcher.go:114-142) — TS uses a single recursive watch, not per-directory fsnotify registration, so the cap doesn't fall out naturally; and the debounce is still trailing-500 ms vs Go's fire-first (watcher.go:102-104) — a semantics change judged too risky to bundle here.

Known residuals (documented, deliberately not fixed here)

  • serve does not decrypt dotenvx encrypted: secret values (pre-existing packages/config gap; start decrypts explicitly, Go decrypts during config load).
  • Go streams the kong-reload exec output live to stderr; TS only surfaces captured stderr in the failure warning.
  • The not-found message supabase start is not running. lacks Go's Aqua color on "supabase start" (pre-existing).
  • The fs.watch rename→create/delete classification has no direct test (real-watcher tests are flaky); the printed-token mapping is covered via the mocked watcher.

Fixes CLI-1984
https://linear.app/supabase/issue/CLI-1984/functions-serve-parity-docker-down-error-kong-reload-args-edge

@Coly010

Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfdda3a730

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1632 to +1635
// A down Docker daemon therefore surfaces from the DB inspect below
// (`assertLocalDbRunning`) as `failed to inspect service: …` with the
// Docker Desktop install hint as a suggestion (`misc.go:155-166`), never as
// an upfront `failed to run docker.` failure.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the Docker-install hint when no runtime is installed

When neither docker nor podman is installed or available on PATH, runChildProcess fails during spawning, but assertLocalDbRunning catches that failure and replaces it with an empty stderr. Consequently, legacyIsDockerDaemonUnreachable("") is false and this newly removed precheck turns the previous actionable Docker prerequisite error into only failed to inspect service, without the install suggestion. Preserve the spawn failure or explicitly classify the no-runtime error so first-time users still receive the required guidance.

AGENTS.md reference: apps/cli/AGENTS.md:L246-L256

Useful? React with 👍 / 👎.

Comment on lines 418 to +420
Object.entries(edgeRuntime.secrets ?? {}).flatMap(([name, value]) =>
Redacted.isRedacted(value) ? [[name.toUpperCase(), Redacted.value(value)] as const] : [],
Redacted.isRedacted(value) && Redacted.value(value).length > 0
? [[name, Redacted.value(value)] as const]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore Go's uppercasing of configured secret names

When a [edge_runtime.secrets] key contains lowercase characters, this now injects that key verbatim, but the Go config loader explicitly rewrites every key with strings.ToUpper in apps/cli-go/pkg/config/config.go:766-771 before set.ListSecrets reads it. A function that previously received MY_LOWER_SECRET will therefore receive only my_lower_secret in the legacy TS CLI and can fail at runtime; retaining name.toUpperCase() is required for Go parity.

AGENTS.md reference: apps/cli/AGENTS.md:L246-L256

Useful? React with 👍 / 👎.

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