Aias00 opened a new issue, #7456: URL: https://github.com/apache/shenyu/issues/7456
## Is there an existing issue for this? - [x] I searched open and closed issues. ## Current Behavior Plugin-handle import silently skips a valid handle when the target plugin already has a handle with the same `field` but a different `type`. `PluginHandleServiceImpl.importData()` groups existing rows by plugin and creates a duplicate set from `field` only. The persistence uniqueness contract is `(plugin_id, field, type)`. Seed data relies on distinct types sharing fields, including Cache `cacheType`, `database` and `url`. ## Expected Behavior After remapping the plugin ID, compare handles using the same logical identity as persistence. An existing `(P, F, type=1)` must not suppress an imported `(P, F, type=2)`. ## Steps To Reproduce 1. The target plugin `P` has one handle with `field=sharedField,type=1`. 2. Prepare an import with a handle for the same mapped target plugin, `field=sharedField,type=2`. 3. Import through `plugin_handle.json` or call the real service's `importData()` with the plugin ID mapping populated. 4. Observe success with zero inserted handles rather than insertion of the distinct type. The current-source service harness with mocked mapper/publisher dependencies observed: ```text existing=(pluginId=new-plugin, field=sharedField, type=1) imported=(pluginId=old-plugin->new-plugin, field=sharedField, type=2) successCount=0 insertCount=0 importHandlePluginIdAfterCall=old-plugin ``` ## Location And Impact - [PluginHandleServiceImpl.java:175](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/PluginHandleServiceImpl.java#L175): builds a field-only duplicate set. - [PluginHandleServiceImpl.java:179](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/PluginHandleServiceImpl.java#L179): skips the distinct type before insertion/remapping. - [H2 schema:45](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-admin/src/main/resources/sql-script/h2/schema.sql#L45): plugin_handle uniqueness includes type. - [PluginHandleDataConfigsExportImportHandler.java:58](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/configs/PluginHandleDataConfigsExportImportHandler.java#L58): import entry point. Severity: Medium. Confidence: high. Imported selector/rule/plugin form metadata can be incomplete after migration, while the import returns a successful result. ## Suggested Fix And Regression Coverage Use `(field,type)` identity within each mapped target plugin, consistent with the database uniqueness constraint. Cover same-field/different-type insertion, exact duplicate skipping, plugin ID remapping and multiple imported handles. ## Validation And Related Issues Reviewed ShenYu `2.7.2-SNAPSHOT` master at `67596c1d228b62da75cd0a0ecb47d0ac5d995384`. An isolated verifier and leader execution of the real current service confirmed the silent skip. Existing `PluginHandleServiceTest,PluginHandleServiceImplTest`: 11 tests passed, but do not cover this type-distinct import. Closed #5996 concerns an insert failing because plugin_id was missing. This case succeeds without insertion because duplicate detection ignores type; no matching issue was found. The new reproduction used mocked persistence and direct schema evidence, not a live database or full HTTP import flow. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
