nanxiuzi opened a new pull request, #18637: URL: https://github.com/apache/dolphinscheduler/pull/18637
<!--Thanks for contributing to Apache DolphinScheduler. Please review https://dolphinscheduler.apache.org/en-us/community/development/contribute.html before opening a pull request.--> <!-- * Title: [Type-ISSUE_ID][Module] Subject * Prefix your PR title with [Fix-1234] or [Feature-1234] --> ## Purpose of the pull request Fixes #18636. Selecting a resource file fails validation with `未授权或已删除资源` whenever another directory in the resource tree shares a name prefix with the file's parent directory (e.g. `datax_to_doris` vs `datax_to_doris2`). The file is listed and selectable, but validation rejects it and the workflow then fails at runtime with file-not-found. ## Brief change log - `dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-resources.ts` - `isDirectory` now matches with `^${res.fullName}(/|$)` instead of `^${res.fullName}`, anchoring the prefix to a path boundary. ## Root cause `isDirectory` decides whether a tree node is an ancestor directory of the target path using a plain prefix regex: ```ts res.dirctory && new RegExp(`^${res.fullName}`).test(fullName) ``` Without a path separator, `^/resources/datax_to_doris` also matches `/resources/datax_to_doris2/foo.json`. The loop returns on the first matching directory, descends into the wrong sibling, never finds the file, and falls through to `addResourceNode(...)` + `return false` — which raises the "unauthorized or deleted resource" error. ## Verify this change - Old regex, first match → `datax_to_doris` (wrong directory). - New regex, first match → `datax_to_doris2` (correct directory). ``` naive first-match dir : datax_to_doris (wrong) fixed first-match dir : datax_to_doris2 (correct) ``` Manual steps: 1. Create `datax_to_doris` and `datax_to_doris2` in the resource center, upload a file into `datax_to_doris2`. 2. In a task node, open the resource dropdown and select that file. 3. Before: `未授权或已删除资源: datax_to_doris2/<file>`. After: selection passes validation and saving/running the workflow works. ## Pull Request Type - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Code refactoring - [ ] Documentation update - [ ] Other (please describe): ## Does this pull request potentially affect one of the following parts - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The core logic - [ ] The DSL - [ ] The RPC - [ ] The UI - [ ] The resources - [ ] The documentation - [ ] The configuration ## AI usage disclosure - [x] This contribution contains AI-generated code, and I have reviewed and tested it myself. - [ ] This contribution does not contain AI-generated code. ## Checklist - [x] *I have read the [CONTRIBUTING](https://github.com/apache/dolphinscheduler/blob/dev/CONTRIBUTING.md) doc* - [x] *I have added labels to this pull request* - [x] *I have added the appropriate milestone to this pull request* - [ ] *I have associated a PR with an issue (required)* - [ ] *I have read the [Code of Conduct](https://www.apache.org/foundation/policies/conduct)* -- 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]
