Skip to content

fix(studio): require a GLiNER model for the anonymizer entity detector [ASTD-336] - #957

Merged
marcusds merged 6 commits into
mainfrom
astd-336-gliner-detector-guard/mschwab
Jul 28, 2026
Merged

marcusds merged 6 commits into
mainfrom
astd-336-gliner-detector-guard/mschwab

Conversation

@marcusds

@marcusds marcusds commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes ASTD-336.

The builder defaulted entity_detector to the general LLM whenever the workspace had no GLiNER model:

const gliner = models.find((model) => isGliner(model.name)) ?? llm;

That fallback can never work. The library injects GLiNER-only inference params into whatever model the detector alias points at, with no model-type check:

# anonymizer/engine/detection/detection_workflow.py  _inject_detector_params
config.inference_parameters.extra_body["labels"] = labels
config.inference_parameters.extra_body["threshold"] = gliner_detection_threshold
config.inference_parameters.extra_body["chunk_length"] = 384
config.inference_parameters.extra_body["overlap"] = 128
config.inference_parameters.extra_body["flat_ner"] = False

so a chat endpoint rejects them and the job dies mid-run:

Validation: Unsupported parameter(s): `overlap`, `threshold`, `flat_ner`, `labels`, `chunk_length`
Cause: ... unsupported by model 'nvidia/nemotron-3-nano-30b-a3b' while running health checks.

Affects all five strategies — every one runs detection. Pre-existing since ASTD-327.

Change

  • The Entity Detector picker offers only GLiNER models instead of the full workspace list.
  • No fallback: with no GLiNER model the role stays empty rather than pre-filled with something that cannot run.
  • The empty state says what's missing — "No GLiNER model in this workspace. Entity detection needs one, such as nvidia/gliner-pii."

An unset role already fails the existing per-role validation, so submit is blocked with an inline error and the tab switches to Model Settings. The failure moves from a cryptic 400 mid-run to the form itself.

Matching moved to utils.ts and now checks both the served model name and the entity id — the GLiNER model in my workspace registers as model_entity_id: default/nvidia-gliner-pii / served_model_name: nvidia/gliner-PII, and the old check looked at one field only, so a model carrying the name in the other would have been missed. Case-insensitive, as before.

Testing

  • Unit tests for the matcher: both identifiers, mixed case, and non-matching chat models
  • 35 anonymizer tests, typecheck, eslint, prettier clean

Verified both paths in a running Studio against a live platform:

Entity Detector Options offered Empty state
GLiNER registered auto-selects default/nvidia-gliner-pii 1, not all 115 —
GLiNER absent Select a model 0 shown

The second row was produced by rewriting the providers response in-flight to strip GLiNER models, so it exercises the real component rather than a mock.

Not included

The ticket floated an optional warning on the Source tab for users who never open Model Settings. Left out — the submit-time validation already routes them there with an inline error, and a second surface for the same message seemed like noise. Easy to add if you disagree.

Summary by CodeRabbit

  • New Features
    • Updated model selection to show only compatible GLiNER options when the GLiNER role is chosen.
    • Added role-aware validation with an explicit error message when a GLiNER model is required but missing.
  • Bug Fixes
    • Improved default model selection so non-GLiNER roles exclude GLiNER models, and the GLiNER role uses GLiNER-only defaults.
    • Avoided applying defaults when no compatible model exists for a role.
  • Tests
    • Added unit tests for GLiNER model identification (case-insensitive, workspace-independent matching).

…r [ASTD-336]

The detector role was defaulted to the general LLM when no GLiNER model was
registered, which always produced a config that dies at detection: the library
injects GLiNER-only params (labels, threshold, chunk_length, overlap, flat_ner)
into whatever that role points at, and a chat endpoint rejects them with a 400.

Restrict the picker to GLiNER models, drop the fallback so the role stays empty
rather than pre-filled with something unusable, and say why in the empty state.
An unset role already blocks submit through the existing role validation, so the
failure now surfaces in the form instead of mid-run.

Matching moves to a shared helper that checks the served model name as well as
the entity id, since either may carry the name depending on how the model was
registered.

Signed-off-by: mschwab <mschwab@nvidia.com>
@marcusds
marcusds requested review from a team as code owners July 28, 2026 21:14
@github-actions github-actions Bot added the fix label Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ad54ba1a-52fc-4b89-8924-fb4f9b459e6f

📥 Commits

Reviewing files that changed from the base of the PR and between 1593c75 and b6649d0.

📒 Files selected for processing (1)
  • web/packages/studio/src/routes/AnonymizerBuilderRoute/components/ModelSettingsSection.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/packages/studio/src/routes/AnonymizerBuilderRoute/components/ModelSettingsSection.tsx

📝 Walkthrough

Walkthrough

The Anonymizer Builder centralizes GLiNER model detection, separates GLiNER and LLM defaults, and applies role-specific model options and validation in the model settings selector.

Changes

GLiNER model selection

Layer / File(s) Summary
Shared GLiNER detection and role defaults
web/packages/studio/src/routes/AnonymizerBuilderRoute/utils.ts, web/packages/studio/src/routes/AnonymizerBuilderRoute/utils.test.ts, web/packages/studio/src/routes/AnonymizerBuilderRoute/useDefaultRoleModels.ts
Adds and tests case-insensitive GLiNER detection, excludes GLiNER models from LLM defaults, and skips GLiNER role seeding when none is available.
Role-aware model options
web/packages/studio/src/routes/AnonymizerBuilderRoute/components/ModelSettingsSection.tsx
Provides GLiNER-only options for the GLiNER role and displays a required-model error when no GLiNER model is available.

Sequence Diagram(s)

sequenceDiagram
  participant ModelSettingsSection
  participant isGlinerModel
  participant ControlledSearchableSelect
  ModelSettingsSection->>isGlinerModel: classify available models
  isGlinerModel-->>ModelSettingsSection: identify GLiNER options
  ModelSettingsSection->>ControlledSearchableSelect: provide role-specific options and validation
Loading

Possibly related PRs

Suggested reviewers: steramae-nvidia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately summarizes the main change: requiring a GLiNER model for the anonymizer entity detector in Studio.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch astd-336-gliner-detector-guard/mschwab
🔧 Fix failing CI
  • Fix failing CI in branch astd-336-gliner-detector-guard/mschwab

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
web/packages/studio/src/routes/AnonymizerBuilderRoute/utils.test.ts (1)

7-14: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test entity-ID matching explicitly.

The helper sets id equal to name, so these tests do not verify the required ID-only case. A regression that ignores model.id would still pass.

Proposed test fixture update
-const model = (name: string, servedModelName: string): DataDesignerModelOption =>
-  ({ id: name, name, served_model_name: servedModelName }) as DataDesignerModelOption;
+const model = (id: string, name: string, servedModelName: string): DataDesignerModelOption =>
+  ({ id, name, served_model_name: servedModelName }) as DataDesignerModelOption;

+expect(isGlinerModel(model('nvidia/gliner-pii', 'pii-detector', ''))).toBe(true);
🤖 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/utils.test.ts` around
lines 7 - 14, Update the isGlinerModel test fixtures so at least one case uses a
model id containing the GLiNER identifier while its name does not, explicitly
verifying ID-only matching. Adjust the model helper or add a fixture that allows
id and name to differ, while preserving the existing case-insensitive and
served_model_name coverage.
🤖 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/useDefaultRoleModels.ts`:
- Around line 31-42: Update the default LLM selection in useDefaultRoleModels so
every fallback excludes models matching isGlinerModel, including the
suggested-name lookup and final fallback to models[0]. Keep gliner selection
unchanged for GLINER_ROLE, while ensuring non-detector roles never receive a
GLiNER model.

In `@web/packages/studio/src/routes/AnonymizerBuilderRoute/utils.ts`:
- Around line 10-11: Update isGlinerModel to match the GLiNER entity identifier
against model.id, while preserving the existing case-insensitive matching
behavior and optional handling for other model fields as appropriate.

---

Nitpick comments:
In `@web/packages/studio/src/routes/AnonymizerBuilderRoute/utils.test.ts`:
- Around line 7-14: Update the isGlinerModel test fixtures so at least one case
uses a model id containing the GLiNER identifier while its name does not,
explicitly verifying ID-only matching. Adjust the model helper or add a fixture
that allows id and name to differ, while preserving the existing
case-insensitive and served_model_name coverage.
🪄 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: d4b854b0-01ae-40c6-aa93-885d83f1a7dd

📥 Commits

Reviewing files that changed from the base of the PR and between e39c168 and b4c9453.

📒 Files selected for processing (4)
  • web/packages/studio/src/routes/AnonymizerBuilderRoute/components/ModelSettingsSection.tsx
  • web/packages/studio/src/routes/AnonymizerBuilderRoute/useDefaultRoleModels.ts
  • web/packages/studio/src/routes/AnonymizerBuilderRoute/utils.test.ts
  • web/packages/studio/src/routes/AnonymizerBuilderRoute/utils.ts

@github-actions

github-actions Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 27601/35351 78.1% 62.5%
Integration Tests 16112/34069 47.3% 19.8%

…336]

The explanation only appeared inside the detector's dropdown, so it was
invisible until the menu was opened. It is now a field error on the input —
red border plus message — visible as soon as Model Settings is shown. The
menu keeps the plain no-models empty state.

Signed-off-by: mschwab <mschwab@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/studio/src/routes/AnonymizerBuilderRoute/components/ModelSettingsSection.tsx (1)

57-57: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Clear stale detector values when the model is no longer GLiNER.

optionsForRole(role) only filters the dropdown; ControlledSearchableSelect keeps the existing value, and useDefaultRoleModels.ts skips any truthy roleModels.${role}.modelId. That lets an old non-GLiNER entity_detector keep its model/provider and be submitted. Clear or revalidate the detector fields when its selected model is no longer GLiNER.

🤖 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/components/ModelSettingsSection.tsx`
at line 57, Update the detector model handling in ModelSettingsSection and its
ControlledSearchableSelect usage so changing away from a GLiNER model clears or
revalidates the detector model and provider fields, rather than only filtering
options via optionsForRole(role). Ensure stale entity_detector values cannot
remain truthy and be submitted or bypass useDefaultRoleModels.ts defaults.
🤖 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.

Outside diff comments:
In
`@web/packages/studio/src/routes/AnonymizerBuilderRoute/components/ModelSettingsSection.tsx`:
- Line 57: Update the detector model handling in ModelSettingsSection and its
ControlledSearchableSelect usage so changing away from a GLiNER model clears or
revalidates the detector model and provider fields, rather than only filtering
options via optionsForRole(role). Ensure stale entity_detector values cannot
remain truthy and be submitted or bypass useDefaultRoleModels.ts defaults.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e3741696-c973-4577-a19e-1e1b6a7af3fc

📥 Commits

Reviewing files that changed from the base of the PR and between b4c9453 and ecbe1b0.

📒 Files selected for processing (1)
  • web/packages/studio/src/routes/AnonymizerBuilderRoute/components/ModelSettingsSection.tsx

marcusds added 2 commits July 28, 2026 14:55
pickDefaultModelName only filters NON_LLM_TERMS, which has no gliner entry, so
a GLiNER model could win the suggested-name lookup or the array fallback and be
seeded into the validator, augmenter and rewrite roles — the mirror of the bug
this branch fixes. Draw those defaults from the non-GLiNER models only.

Signed-off-by: mschwab <mschwab@nvidia.com>
Both helpers were single expressions used once, and the formFieldProps one
repeated slotLabel/required across its branches.

Signed-off-by: mschwab <mschwab@nvidia.com>
@marcusds
marcusds enabled auto-merge July 28, 2026 22:25
@marcusds
marcusds added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit c6be49d Jul 28, 2026
56 checks passed
@marcusds
marcusds deleted the astd-336-gliner-detector-guard/mschwab branch July 28, 2026 23:22
ngoncharenko pushed a commit that referenced this pull request Jul 29, 2026
…r [ASTD-336] (#957)

* fix(studio): require a GLiNER model for the anonymizer entity detector [ASTD-336]

The detector role was defaulted to the general LLM when no GLiNER model was
registered, which always produced a config that dies at detection: the library
injects GLiNER-only params (labels, threshold, chunk_length, overlap, flat_ner)
into whatever that role points at, and a chat endpoint rejects them with a 400.

Restrict the picker to GLiNER models, drop the fallback so the role stays empty
rather than pre-filled with something unusable, and say why in the empty state.
An unset role already blocks submit through the existing role validation, so the
failure now surfaces in the form instead of mid-run.

Matching moves to a shared helper that checks the served model name as well as
the entity id, since either may carry the name depending on how the model was
registered.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix(studio): surface the missing GLiNER model as a field error [ASTD-336]

The explanation only appeared inside the detector's dropdown, so it was
invisible until the menu was opened. It is now a field error on the input —
red border plus message — visible as soon as Model Settings is shown. The
menu keeps the plain no-models empty state.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix(studio): keep GLiNER out of the chat-role defaults [ASTD-336]

pickDefaultModelName only filters NON_LLM_TERMS, which has no gliner entry, so
a GLiNER model could win the suggested-name lookup or the array fallback and be
seeded into the validator, augmenter and rewrite roles — the mirror of the bug
this branch fixes. Draw those defaults from the non-GLiNER models only.

Signed-off-by: mschwab <mschwab@nvidia.com>

* refactor(studio): inline the per-role model field props [ASTD-336]

Both helpers were single expressions used once, and the formFieldProps one
repeated slotLabel/required across its branches.

Signed-off-by: mschwab <mschwab@nvidia.com>

---------

Signed-off-by: mschwab <mschwab@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants