-
Notifications
You must be signed in to change notification settings - Fork 329
feat(docs): add opt-in mask-pii setting for Ask AI #17040
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # yaml-language-server: $schema=../../../../../fern-changes-yml.schema.json | ||
|
|
||
| - summary: | | ||
| Add an opt-in `mask-pii` setting under `ai-search` in docs.yml. When enabled, personally | ||
| identifiable information (PII) in user messages is masked before being sent to Ask Fern. | ||
| Disabled by default. | ||
| type: feat |
61 changes: 61 additions & 0 deletions
61
packages/cli/configuration-loader/src/docs-yml/__test__/aiSearchMaskPii.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,61 @@ | ||
| import { docsYml } from "@fern-api/configuration"; | ||
| import { AbsoluteFilePath } from "@fern-api/fs-utils"; | ||
| import { createMockTaskContext } from "@fern-api/task-context"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { parseDocsConfiguration } from "../parseDocsConfiguration.js"; | ||
|
|
||
| const FAKE_FERN_DIR = "/fern" as AbsoluteFilePath; | ||
| const FAKE_CONFIG_PATH = "/fern/docs.yml" as AbsoluteFilePath; | ||
|
|
||
| async function parseRawDocsYml(rawDocsYml: unknown): Promise<docsYml.ParsedDocsConfiguration> { | ||
| // mirrors loadDocsWorkspace: kebab-case docs.yml keys -> camelCase raw config | ||
| const rawDocsConfiguration = docsYml.RawSchemas.Serializer.DocsConfiguration.parseOrThrow(rawDocsYml); | ||
| return await parseDocsConfiguration({ | ||
| rawDocsConfiguration, | ||
| absolutePathToFernFolder: FAKE_FERN_DIR, | ||
| absoluteFilepathToDocsConfig: FAKE_CONFIG_PATH, | ||
| context: createMockTaskContext() | ||
| }); | ||
| } | ||
|
|
||
| describe("parseDocsConfiguration — ai-search.mask-pii", () => { | ||
| it("is undefined (masking off) when the ai-search key is omitted", async () => { | ||
| const parsed = await parseRawDocsYml({ instances: [], navigation: [] }); | ||
| expect(parsed.aiChatConfig?.maskPii).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("is undefined (masking off) when mask-pii is omitted", async () => { | ||
| const parsed = await parseRawDocsYml({ | ||
| instances: [], | ||
| navigation: [], | ||
| "ai-search": {} | ||
| }); | ||
| expect(parsed.aiChatConfig?.maskPii).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("maps the kebab-case mask-pii key to the camelCase maskPii field", async () => { | ||
| const enabled = await parseRawDocsYml({ | ||
| instances: [], | ||
| navigation: [], | ||
| "ai-search": { "mask-pii": true } | ||
| }); | ||
| expect(enabled.aiChatConfig?.maskPii).toBe(true); | ||
|
|
||
| const disabled = await parseRawDocsYml({ | ||
| instances: [], | ||
| navigation: [], | ||
| "ai-search": { "mask-pii": false } | ||
| }); | ||
| expect(disabled.aiChatConfig?.maskPii).toBe(false); | ||
| }); | ||
|
|
||
| it("also honors mask-pii under the deprecated ai-chat key", async () => { | ||
| const parsed = await parseRawDocsYml({ | ||
| instances: [], | ||
| navigation: [], | ||
| "ai-chat": { "mask-pii": true } | ||
| }); | ||
| expect(parsed.aiChatConfig?.maskPii).toBe(true); | ||
| }); | ||
| }); |
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
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
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.
🔴 critical
this.parsedDocsConfig.aiChatConfigoriginates from the zodAIChatConfigschema, where the field is"mask-pii", notmaskPii. Unless there's a serialization step between the zod-parsed config andparsedDocsConfigthat converts to camelCase (the generated SDK serialization does, but the zod schema doesn't),this.parsedDocsConfig.aiChatConfig.maskPiiwill always beundefinedand the setting will silently never propagate. Verify which typeparsedDocsConfig.aiChatConfigactually is and use the matching key.