Fix: RAPTOR "Generation scope" reset to "Single file" when selecting "Dataset" (#14477)

## Problem
In the Dataset Configuration page, changing the RAPTOR **Generation
scope** from "Single file" to "Dataset" and clicking **Save** did not
persist the change. After refreshing or re-entering the page, the scope
always reverted to "Single file".

## Root Cause
1. **Backend**: The `RaptorConfig` Pydantic model in
`api/utils/validation_utils.py` was configured with `extra="forbid"` but
did not declare a `scope` field. When the frontend sent `"scope":
"dataset"`, Pydantic rejected the request.
2. **Frontend**: The `extractRaptorConfigExt` utility in
`web/src/hooks/parser-config-utils.ts` treated `scope` as an unknown
field and moved it into the nested `ext` object. Consequently, the
backend could not read `raptor_config.get("scope", "file")` correctly,
so the default `"file"` was always used.

## Changes
- Added `scope: Literal["file", "dataset"]` to the backend
`RaptorConfig` model with a default of `"file"`.
- Added `scope` to the known-field whitelist in the frontend
`extractRaptorConfigExt` helper so it is transmitted as a top-level
raptor field instead of being buried in `ext`.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Signed-off-by: noob <yixiao121314@outlook.com>
This commit is contained in:
euvre
2026-04-29 10:46:28 +00:00
committed by GitHub
parent 1b84892e3a
commit a0f9ae16d2
2 changed files with 24 additions and 25 deletions

View File

@@ -20,6 +20,7 @@ export const extractRaptorConfigExt = (
threshold,
max_cluster,
random_seed,
scope,
auto_disable_for_structured_data,
ext,
...raptorExt
@@ -31,6 +32,7 @@ export const extractRaptorConfigExt = (
threshold,
max_cluster,
random_seed,
scope,
auto_disable_for_structured_data,
ext: { ...ext, ...raptorExt },
};