-
Notifications
You must be signed in to change notification settings - Fork 52
fix: gate agentcore run ingest behind ENABLE_GATED_FEATURES
#1619
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
+88
−6
Merged
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { runCLI } from '../../../../test-utils/index.js'; | ||
| import { randomUUID } from 'node:crypto'; | ||
| import { mkdir, rm } from 'node:fs/promises'; | ||
| import { tmpdir } from 'node:os'; | ||
| import { join } from 'node:path'; | ||
| import { afterAll, beforeAll, describe, expect, it } from 'vitest'; | ||
|
|
||
| /** | ||
| * Knowledge bases (FMKB) are gated behind ENABLE_GATED_FEATURES. `agentcore run | ||
| * ingest` operates exclusively on knowledge bases, so it must be gated to match | ||
| * `add knowledge-base` / `remove knowledge-base`. These tests drive the built | ||
| * CLI so we exercise the actual commander registration (hidden command + the | ||
| * in-action guard). | ||
| */ | ||
| describe('run ingest command — FMKB gating', () => { | ||
| let testDir: string; | ||
| let projectDir: string; | ||
|
|
||
| beforeAll(async () => { | ||
| testDir = join(tmpdir(), `agentcore-run-ingest-${randomUUID()}`); | ||
| await mkdir(testDir, { recursive: true }); | ||
| const projectName = 'TestProj'; | ||
| // Create the project with gated features enabled so the KB add path is | ||
| // available; the ingest gating is exercised separately below. | ||
| const result = await runCLI(['create', '--name', projectName, '--no-agent'], testDir); | ||
| if (result.exitCode !== 0) { | ||
| throw new Error(`Failed to create project: ${result.stdout} ${result.stderr}`); | ||
| } | ||
| projectDir = join(testDir, projectName); | ||
| }); | ||
|
|
||
| afterAll(async () => { | ||
| await rm(testDir, { recursive: true, force: true }); | ||
| }); | ||
|
|
||
| it('rejects `run ingest` when ENABLE_GATED_FEATURES is not set', async () => { | ||
| const result = await runCLI(['run', 'ingest', '--name', 'kb-default', '--json'], projectDir); | ||
| expect(result.exitCode, `stdout: ${result.stdout}, stderr: ${result.stderr}`).toBe(1); | ||
|
tejaskash marked this conversation as resolved.
|
||
| expect(result.stderr).toContain('Knowledge bases are not yet available.'); | ||
| }); | ||
|
|
||
| it('hides `ingest` from `run --help` when ENABLE_GATED_FEATURES is not set', async () => { | ||
| const result = await runCLI(['run', '--help'], projectDir); | ||
| expect(result.exitCode).toBe(0); | ||
| expect(result.stdout).not.toContain('ingest'); | ||
| }); | ||
|
|
||
| it('exposes `ingest` in `run --help` when ENABLE_GATED_FEATURES=1', async () => { | ||
| const result = await runCLI(['run', '--help'], projectDir, { env: { ENABLE_GATED_FEATURES: '1' } }); | ||
| expect(result.exitCode).toBe(0); | ||
| expect(result.stdout).toContain('ingest'); | ||
| }); | ||
|
|
||
| it('passes the gate (fails later on validation) when ENABLE_GATED_FEATURES=1', async () => { | ||
| // With the gate open, the command proceeds past the FMKB guard. We pass an | ||
| // unknown KB name so it fails on the validation step rather than the gate — | ||
| // proving the gate no longer blocks the command. | ||
| const result = await runCLI(['run', 'ingest', '--name', 'does-not-exist', '--json'], projectDir, { | ||
| env: { ENABLE_GATED_FEATURES: '1' }, | ||
| }); | ||
| expect(result.exitCode).toBe(1); | ||
| const combined = `${result.stdout} ${result.stderr}`; | ||
| expect(combined).not.toContain('Knowledge bases are not yet available.'); | ||
| expect(combined).toContain('does-not-exist'); | ||
| }); | ||
| }); | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment/code mismatch: the comment says "Create the project with gated features enabled so the KB add path is available", but no
env: { ENABLE_GATED_FEATURES: '1' }is passed to thisrunCLIcall, and the test never actually adds a KB to the project. Please either drop the comment or align it with what the test does (just creating a bare project for the ingest invocations).