-
Notifications
You must be signed in to change notification settings - Fork 493
fix(cli): wire --experimental gate into 7 ungated native leaves #5766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Coly010
merged 6 commits into
develop
from
columferry/cli-1854-wire-the-experimental-gate-into-the-7-ungated-native-leaves
Jul 6, 2026
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2443cfc
fix(cli): wire --experimental gate into 7 ungated native management-A…
Coly010 127fd49
fix(cli): validate --output enum before the experimental gate (review…
Coly010 0d35747
test(cli): isolate experimental-gate tests from ambient env/keyring (…
Coly010 06509cf
Merge remote-tracking branch 'origin/develop' into columferry/cli-185…
Coly010 30ffe1e
test(cli): isolate gate-open tests from the credentials file-fallback…
Coly010 e5ee27e
docs(cli): document the --experimental gate in the 7 newly-gated leav…
Coly010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
107 changes: 107 additions & 0 deletions
107
apps/cli/src/legacy/commands/network-bans/network-bans.experimental-gate.integration.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import { describe, expect, it } from "@effect/vitest"; | ||
| import { Effect, Exit, Layer } from "effect"; | ||
| import { CliOutput, Command } from "effect/unstable/cli"; | ||
|
|
||
| import { textCliOutputFormatter } from "../../../shared/output/text-formatter.ts"; | ||
| import { LEGACY_GLOBAL_FLAGS } from "../../../shared/legacy/global-flags.ts"; | ||
| import { TelemetryRuntime } from "../../../shared/telemetry/runtime.service.ts"; | ||
| import { makeTelemetryIdentity } from "../../../shared/telemetry/identity.ts"; | ||
| import { mockOutput } from "../../../../tests/helpers/mocks.ts"; | ||
| import { | ||
| buildLegacyTestRuntime, | ||
| mockLegacyCliConfig, | ||
| mockLegacyPlatformApi, | ||
| useLegacyTempWorkdir, | ||
| } from "../../../../tests/helpers/legacy-mocks.ts"; | ||
| import { legacyNetworkBansCommand } from "./network-bans.command.ts"; | ||
|
|
||
| // See postgres-config.experimental-gate.integration.test.ts for the full | ||
| // rationale: this proves `--experimental` is wired into the actual | ||
| // `.command.ts` handler pipeline AND runs before | ||
| // `legacyManagementApiRuntimeLayer`'s eager access-token resolution | ||
| // (Go's `IsExperimental` check precedes `IsManagementAPI` in | ||
| // `apps/cli-go/cmd/root.go:91-109`). | ||
|
|
||
| const tempRoot = useLegacyTempWorkdir("supabase-network-bans-experimental-int-"); | ||
|
|
||
| const testRoot = Command.make("supabase").pipe( | ||
| Command.withGlobalFlags(LEGACY_GLOBAL_FLAGS), | ||
| Command.withSubcommands([legacyNetworkBansCommand]), | ||
| ); | ||
|
|
||
| function setup() { | ||
| const out = mockOutput({ format: "text" }); | ||
| const api = mockLegacyPlatformApi({ | ||
| response: { status: 200, body: { banned_ipv4_addresses: [] } }, | ||
| }); | ||
| const runtime = buildLegacyTestRuntime({ | ||
| out, | ||
| api, | ||
| cliConfig: mockLegacyCliConfig({ workdir: tempRoot.current }), | ||
| }); | ||
| const layer = Layer.mergeAll( | ||
| runtime, | ||
| CliOutput.layer(textCliOutputFormatter()), | ||
| Layer.succeed( | ||
| TelemetryRuntime, | ||
| TelemetryRuntime.of({ | ||
| configDir: `${tempRoot.current}/.supabase`, | ||
| tracesDir: `${tempRoot.current}/.supabase/traces`, | ||
| consent: "granted", | ||
| showDebug: false, | ||
| deviceId: "test-device-id", | ||
| sessionId: "test-session-id", | ||
| identity: makeTelemetryIdentity(undefined), | ||
| isFirstRun: false, | ||
| isTty: false, | ||
| isCi: false, | ||
| os: "linux", | ||
| arch: "x64", | ||
| cliVersion: "0.1.0", | ||
| }), | ||
| ), | ||
| ); | ||
| return { layer, api }; | ||
| } | ||
|
|
||
| describe("legacy network-bans experimental gate (Go PersistentPreRunE parity)", () => { | ||
| const leaves: ReadonlyArray<{ readonly name: string; readonly args: ReadonlyArray<string> }> = [ | ||
| { name: "get", args: ["network-bans", "get"] }, | ||
| { name: "remove", args: ["network-bans", "remove"] }, | ||
| ]; | ||
|
|
||
| for (const { name, args } of leaves) { | ||
| it.live( | ||
| `${name} fails with LegacyExperimentalRequiredError when --experimental is unset`, | ||
| () => { | ||
| const { layer, api } = setup(); | ||
| return Effect.gen(function* () { | ||
| const exit = yield* Effect.exit( | ||
| Command.runWith(testRoot, { version: "0.0.0-test" })(args), | ||
| ); | ||
| expect(Exit.isFailure(exit)).toBe(true); | ||
| if (Exit.isFailure(exit)) { | ||
| expect(JSON.stringify(exit.cause)).toContain("LegacyExperimentalRequiredError"); | ||
| } | ||
| expect(api.requests).toHaveLength(0); | ||
| }).pipe(Effect.provide(layer)); | ||
| }, | ||
| ); | ||
|
|
||
| it.live(`${name} does not fail with the gate error once --experimental is set`, () => { | ||
| const { layer, api } = setup(); | ||
| return Effect.gen(function* () { | ||
| const exit = yield* Effect.exit( | ||
| Command.runWith(testRoot, { version: "0.0.0-test" })([...args, "--experimental"]), | ||
| ); | ||
| expect(Exit.isFailure(exit)).toBe(true); | ||
| if (Exit.isFailure(exit)) { | ||
| const causeText = JSON.stringify(exit.cause); | ||
| expect(causeText).not.toContain("LegacyExperimentalRequiredError"); | ||
| expect(causeText).toContain("LegacyPlatformAuthRequiredError"); | ||
| } | ||
| expect(api.requests).toHaveLength(0); | ||
| }).pipe(Effect.provide(layer)); | ||
| }); | ||
| } | ||
| }); |
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
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
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
118 changes: 118 additions & 0 deletions
118
...src/legacy/commands/postgres-config/postgres-config.experimental-gate.integration.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| import { describe, expect, it } from "@effect/vitest"; | ||
| import { Effect, Exit, Layer } from "effect"; | ||
| import { CliOutput, Command } from "effect/unstable/cli"; | ||
|
|
||
| import { textCliOutputFormatter } from "../../../shared/output/text-formatter.ts"; | ||
| import { LEGACY_GLOBAL_FLAGS } from "../../../shared/legacy/global-flags.ts"; | ||
| import { TelemetryRuntime } from "../../../shared/telemetry/runtime.service.ts"; | ||
| import { makeTelemetryIdentity } from "../../../shared/telemetry/identity.ts"; | ||
| import { mockOutput } from "../../../../tests/helpers/mocks.ts"; | ||
| import { | ||
| buildLegacyTestRuntime, | ||
| mockLegacyCliConfig, | ||
| mockLegacyPlatformApi, | ||
| useLegacyTempWorkdir, | ||
| } from "../../../../tests/helpers/legacy-mocks.ts"; | ||
| import { legacyPostgresConfigCommand } from "./postgres-config.command.ts"; | ||
|
|
||
| // This suite proves the `--experimental` gate is wired into the actual | ||
| // `.command.ts` handler pipeline (not just the shared helper in isolation), | ||
| // and — critically — that it runs BEFORE `legacyManagementApiRuntimeLayer` | ||
| // resolves an access token. Go's root `PersistentPreRunE` checks | ||
| // `IsExperimental` before the `IsManagementAPI` login check | ||
| // (`apps/cli-go/cmd/root.go:91-109`); `legacyManagementApiRuntimeLayer` | ||
| // eagerly fails on a missing token as part of its own layer construction, so | ||
| // wiring the gate anywhere except immediately before that layer is attached | ||
| // would let a missing-token error mask the missing-`--experimental` error. | ||
|
|
||
| const tempRoot = useLegacyTempWorkdir("supabase-postgres-config-experimental-int-"); | ||
|
|
||
| const testRoot = Command.make("supabase").pipe( | ||
| Command.withGlobalFlags(LEGACY_GLOBAL_FLAGS), | ||
| Command.withSubcommands([legacyPostgresConfigCommand]), | ||
| ); | ||
|
|
||
| function setup() { | ||
| const out = mockOutput({ format: "text" }); | ||
| const api = mockLegacyPlatformApi({ | ||
| response: { status: 200, body: { max_connections: 100 } }, | ||
| }); | ||
| const runtime = buildLegacyTestRuntime({ | ||
| out, | ||
| api, | ||
| cliConfig: mockLegacyCliConfig({ workdir: tempRoot.current }), | ||
| }); | ||
| const layer = Layer.mergeAll( | ||
| runtime, | ||
| CliOutput.layer(textCliOutputFormatter()), | ||
| Layer.succeed( | ||
| TelemetryRuntime, | ||
| TelemetryRuntime.of({ | ||
| configDir: `${tempRoot.current}/.supabase`, | ||
| tracesDir: `${tempRoot.current}/.supabase/traces`, | ||
| consent: "granted", | ||
| showDebug: false, | ||
| deviceId: "test-device-id", | ||
| sessionId: "test-session-id", | ||
| identity: makeTelemetryIdentity(undefined), | ||
| isFirstRun: false, | ||
| isTty: false, | ||
| isCi: false, | ||
| os: "linux", | ||
| arch: "x64", | ||
| cliVersion: "0.1.0", | ||
| }), | ||
| ), | ||
| ); | ||
| return { layer, api }; | ||
| } | ||
|
|
||
| describe("legacy postgres-config experimental gate (Go PersistentPreRunE parity)", () => { | ||
| const leaves: ReadonlyArray<{ readonly name: string; readonly args: ReadonlyArray<string> }> = [ | ||
| { name: "get", args: ["postgres-config", "get"] }, | ||
| { name: "update", args: ["postgres-config", "update"] }, | ||
| { name: "delete", args: ["postgres-config", "delete"] }, | ||
| ]; | ||
|
|
||
| for (const { name, args } of leaves) { | ||
| it.live( | ||
| `${name} fails with LegacyExperimentalRequiredError when --experimental is unset`, | ||
| () => { | ||
| const { layer, api } = setup(); | ||
| return Effect.gen(function* () { | ||
| const exit = yield* Effect.exit( | ||
| Command.runWith(testRoot, { version: "0.0.0-test" })(args), | ||
| ); | ||
| expect(Exit.isFailure(exit)).toBe(true); | ||
| if (Exit.isFailure(exit)) { | ||
| expect(JSON.stringify(exit.cause)).toContain("LegacyExperimentalRequiredError"); | ||
|
Coly010 marked this conversation as resolved.
|
||
| } | ||
| // The gate must run before any API call (and before the eager | ||
| // access-token resolution inside `legacyManagementApiRuntimeLayer`) — | ||
| // a closed gate makes zero network requests. | ||
| expect(api.requests).toHaveLength(0); | ||
| }).pipe(Effect.provide(layer)); | ||
| }, | ||
| ); | ||
|
|
||
| it.live(`${name} does not fail with the gate error once --experimental is set`, () => { | ||
| const { layer, api } = setup(); | ||
| return Effect.gen(function* () { | ||
| const exit = yield* Effect.exit( | ||
| Command.runWith(testRoot, { version: "0.0.0-test" })([...args, "--experimental"]), | ||
| ); | ||
| // No real access token is configured in this test environment, so the | ||
| // command still fails — but past the gate, at the auth-resolution step | ||
| // that `legacyManagementApiRuntimeLayer` performs, never with the | ||
| // experimental gate error once the flag is on. | ||
| expect(Exit.isFailure(exit)).toBe(true); | ||
| if (Exit.isFailure(exit)) { | ||
| const causeText = JSON.stringify(exit.cause); | ||
| expect(causeText).not.toContain("LegacyExperimentalRequiredError"); | ||
| expect(causeText).toContain("LegacyPlatformAuthRequiredError"); | ||
|
Coly010 marked this conversation as resolved.
|
||
| } | ||
| expect(api.requests).toHaveLength(0); | ||
| }).pipe(Effect.provide(layer)); | ||
| }); | ||
| } | ||
| }); | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.