Fix: Normalize CompositeBackend Route Prefixes to Prevent Path Truncation #455
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
CompositeBackendhas a path truncation bug when route prefixes are registered without a trailing slash. The bug occurs in thels_infomethod at line 79:This code assumes route prefixes always end with
/, but the constructor accepts prefixes without trailing slashes. This causes path truncation:Bug Example:
Expected Behavior:
Root Cause
The
ls_infomethod (andgrep_raw,glob_info) rely onroute_prefix[:-1]to strip the trailing slash when constructing paths. However, the constructor does not enforce or normalize route prefixes to end with/, leading to inconsistent behavior.Solution
Normalize all route prefixes to end with
/in the__init__method:This ensures:
/workspaceand/workspace/work correctlyroute_prefix[:-1]logic works as designedTesting
Reproduction
Created
test_composite_bug2.pyto reproduce the bug:Result after fix:
Verification
/workspaceand/workspace/route formats work correctlyChanges
__init__Impact
CompositeBackendwith routes not ending in/