Commit 5469784
REST Advanced Paths: Allow sub-directories in entity REST paths (#2999)
- [x] Explore and understand the codebase
- [x] Understand how REST paths are validated and used
- [x] Modify validation to allow forward slashes (/) in entity REST
paths for sub-directories
- [x] Update `GetEntityNameAndPrimaryKeyRouteFromRoute` to handle paths
with sub-directories
- [x] Provide clear error messages for invalid paths (backslash, invalid
chars, etc.)
- [x] Add unit tests for the new functionality
- [x] Build and verify the changes
- [x] Run dotnet format on modified files
- [x] Run code review and address feedback
- [x] Run CodeQL security check (no issues found)
- [x] Address PR feedback:
- Added null-safe fallback for error message in
`ValidateRestPathSettingsForEntity`
- Simplified generic error message to avoid overspecifying allowed
characters
- ~~Documented shortest-prefix matching~~ → **Fixed to use
longest-prefix matching**
- [x] **Fixed routing logic**: Changed from shortest-prefix to
longest-prefix matching (most-specific match wins)
- [x] **Added routing tests**: Tests for sub-directory paths,
longest-prefix matching with overlapping paths
- [x] **Updated XML documentation**: Clarified that entity paths may
contain '/' and use longest-prefix matching
- [x] **Fixed ':' error message**: Changed to neutral "reserved
character" message
- [x] **Refactored test helpers**: Removed duplicate code, all helpers
now delegate to single core helper
- [x] **Enhanced validation**:
- Added 2048-character maximum path length limit
- Added percent-encoding (%) validation - not allowed in config
- Added path traversal pattern validation (`.` and `..` segments
blocked)
- Added tests for trailing slash, whitespace, percent-encoding, and path
traversal patterns
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>⭐ [Enhancement]: REST Advanced Paths</issue_title>
> <issue_description>## What is it?
>
> * The ability to customize REST paths with sub-directories, such as
`/api/sub-directory/books`.
>
> This improvement addresses potential conflicts that arise when
multiple data sources contain entities with the same desired REST path.
For example, you might have an `Item` entity under both an `Invoice` and
a `ShoppingCart`. With the current setup, you might end up with paths
like `/shopping-cart` and `/shopping-cart-item`, when the desired paths
would be `/shopping-cart/item` and `/invoice/item`. This issue becomes
more pronounced as we introduce tenant support across multiple
databases.
>
> ## Questions
>
> 1. How many sub-folders, just one? Yes. Just one.
> 2. Are paths unique across config files? Yes, required.
>
> ## Related issues to close
>
> * #1085
> * #1566</issue_description>
>
> <agent_instructions>Change as little as possible, introduce as little
as possible to accomplish this. Terse code FTW.</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
- Fixes #2373
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: JerryNixon <[email protected]>
Co-authored-by: RubenCerna2079 <[email protected]>
Co-authored-by: Aniruddh Munde <[email protected]>
Co-authored-by: Aniruddh25 <[email protected]>
Co-authored-by: anushakolan <[email protected]>1 parent 20df64c commit 5469784
5 files changed
Lines changed: 260 additions & 45 deletions
File tree
- src
- Core
- Configurations
- Services
- Service.Tests/UnitTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
| 659 | + | |
659 | 660 | | |
660 | 661 | | |
661 | 662 | | |
| |||
672 | 673 | | |
673 | 674 | | |
674 | 675 | | |
675 | | - | |
| 676 | + | |
676 | 677 | | |
677 | 678 | | |
678 | | - | |
| 679 | + | |
679 | 680 | | |
680 | 681 | | |
681 | 682 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
69 | 157 | | |
70 | 158 | | |
71 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
437 | | - | |
438 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
439 | 439 | | |
440 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
441 | 447 | | |
442 | 448 | | |
443 | 449 | | |
| |||
448 | 454 | | |
449 | 455 | | |
450 | 456 | | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
463 | 463 | | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
468 | 471 | | |
469 | 472 | | |
470 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
471 | 478 | | |
472 | 479 | | |
473 | 480 | | |
| |||
Lines changed: 30 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2066 | 2066 | | |
2067 | 2067 | | |
2068 | 2068 | | |
2069 | | - | |
| 2069 | + | |
2070 | 2070 | | |
2071 | | - | |
2072 | | - | |
2073 | | - | |
2074 | | - | |
2075 | | - | |
2076 | | - | |
2077 | | - | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
2078 | 2078 | | |
2079 | | - | |
2080 | | - | |
| 2079 | + | |
| 2080 | + | |
2081 | 2081 | | |
2082 | 2082 | | |
2083 | 2083 | | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
2084 | 2104 | | |
2085 | 2105 | | |
2086 | 2106 | | |
| |||
0 commit comments