Repository navigation
feat(studio): Redact/Annotate/Hash strategy params [ASTD-333] - #898
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds strategy-specific anonymizer parameters and payload construction for redact, annotate, and hash strategies. The route parses API validation errors into field-level and general messages, while the UI renders conditional controls and excludes rewrite from available options. ChangesAnonymizer Builder enhancements
Sequence Diagram(s)sequenceDiagram
participant GenerationSection
participant anonymizerFormSchema
participant AnonymizerBuilderRoute
participant parseAnonymizerApiError
participant FormState
GenerationSection->>anonymizerFormSchema: submit strategy-specific values
anonymizerFormSchema->>AnonymizerBuilderRoute: provide validated form data
AnonymizerBuilderRoute->>parseAnonymizerApiError: parse API validation failure
parseAnonymizerApiError->>AnonymizerBuilderRoute: return fieldErrors and generalMessages
AnonymizerBuilderRoute->>FormState: set form and submit errors
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
web/packages/studio/src/routes/AnonymizerBuilderRoute/apiErrors.ts (1)
8-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMark interface fields
readonly.
PydanticErrorandParsedApiErrorfields aren't markedreadonly.As per coding guidelines: "Use
readonlyfor immutable properties in TypeScript interfaces and types."♻️ Add readonly modifiers
interface PydanticError { - loc: (string | number)[]; - msg: string; + readonly loc: (string | number)[]; + readonly msg: string; } export interface ParsedApiError { - fieldErrors: { field: FormField; message: string }[]; - generalMessages: string[]; + readonly fieldErrors: { field: FormField; message: string }[]; + readonly generalMessages: string[]; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/packages/studio/src/routes/AnonymizerBuilderRoute/apiErrors.ts` around lines 8 - 16, Mark all properties in the PydanticError and ParsedApiError interfaces as readonly, including loc, msg, fieldErrors, and generalMessages, without changing their types or structure.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/packages/studio/src/routes/AnonymizerBuilderRoute/schema.ts`:
- Around line 54-59: Update the schema’s hashAlgorithm validation to derive its
allowed values from the shared HASH_ALGORITHM_OPTIONS/HashAlgorithmOption
definitions in constants.ts instead of hardcoding the enum literals. Preserve
the existing validation behavior while ensuring future algorithm additions
remain synchronized with the dropdown options.
---
Nitpick comments:
In `@web/packages/studio/src/routes/AnonymizerBuilderRoute/apiErrors.ts`:
- Around line 8-16: Mark all properties in the PydanticError and ParsedApiError
interfaces as readonly, including loc, msg, fieldErrors, and generalMessages,
without changing their types or structure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f5c49bc3-3505-4118-876e-2bcbe0fdc15c
📒 Files selected for processing (8)
web/packages/studio/src/routes/AnonymizerBuilderRoute/apiErrors.test.tsweb/packages/studio/src/routes/AnonymizerBuilderRoute/apiErrors.tsweb/packages/studio/src/routes/AnonymizerBuilderRoute/components/GenerationSection.tsxweb/packages/studio/src/routes/AnonymizerBuilderRoute/components/StrategyParamsSection.tsxweb/packages/studio/src/routes/AnonymizerBuilderRoute/constants.tsweb/packages/studio/src/routes/AnonymizerBuilderRoute/index.tsxweb/packages/studio/src/routes/AnonymizerBuilderRoute/schema.test.tsweb/packages/studio/src/routes/AnonymizerBuilderRoute/schema.ts
|
Unlock Redact/Annotate/Hash in the strategy select (Rewrite stays locked) and add their parameter fields (format templates, normalize checkbox, hash algorithm + digest length). Wire params into config.replace, omitting empty templates. Surface backend validation 422s inline: parse the pydantic detail and map each loc to its form field via a reusable helper, falling back to the banner for unmapped errors. Signed-off-by: mschwab <mschwab@nvidia.com>
…[ASTD-333] Signed-off-by: mschwab <mschwab@nvidia.com>
Preflight health checks hammered the models and blew provider rate limits (e.g. nvidia/gliner-pii) before the workflow ran. Set skip_health_check on each model_config so the actual anonymization calls carry the budget. Signed-off-by: mschwab <mschwab@nvidia.com>
Signed-off-by: mschwab <mschwab@nvidia.com>
Derive HashAlgorithmOption, the dropdown options, and the zod enum from one HASH_ALGORITHM_VALUES tuple so a new algorithm can't be added in one place and silently fail validation in the other. Mark anonymizer apiErrors interface fields readonly. Signed-off-by: mschwab <mschwab@nvidia.com>
77764f3 to
d0ed611
Compare
What
Adds the parameter UIs for the deterministic replace strategies — Redact / Annotate / Hash — in the Anonymizer builder (ASTD-333). Part of ASTD-215; builds on the merged builder (#884).
Changes
StrategyParamsSectionrenders per-strategy fields below the strategy dropdown:{…}placeholder syntax). Params flow intoconfig.replacealongside thekindtag; empty templates are omitted so the backend default applies.replacement_generatorrole (detection-only mapping already handled).Backend-driven inline validation
The anonymizer returns clean, specific 422s for bad templates (e.g.
template is missing required placeholders: textat…replace.annotate.format_template). Rather than duplicate the rules client-side, on createonErrorwe parse the pydanticdetail[]and map eachlocto its form field via a reusable helper (apiErrors.ts), callingsetErrorfor an inline message — with the banner as fallback for unmapped errors (e.g. model/provider issues).Testing
schema.test.ts(12) — strategykind+ params, empty-template omission, model/label mapping.apiErrors.test.ts(4) —loc→ field mapping (templates, hash params,data.source), unmapped → general, non-422 → empty.@nemo/studiotsc— no new errors from this branch (pre-existing customizer + insights-SDK drift on main, unchanged). eslint + prettier clean.Gated behind
VITE_FF_ANONYMIZER_ENABLED(default false).Notes
Summary by CodeRabbit