fix: generate valid sample URIs for custom route placeholders #10206
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.36) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 195 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.316
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #10206"
general
weight: 0.35
neznaika0
Description
Fixes #9804 - Route Filters are shown as
<unknown>when custom placeholders are used.Problem
When using
addPlaceholder()to define custom route placeholders (e.g.,(:code)), thephp spark routescommand shows<unknown>for filters on those routes. This happens becauseSampleURIGeneratoronly had predefined sample values for built-in placeholders (any,segment,num,alpha,alphanum,hash).When an unknown placeholder is encountered, it fell back to
::unknown::which does not match the actual regex pattern. This causedFilterFinderto throwPageNotFoundExceptionwhen trying to route the sample URI, resulting in<unknown>filter display.Solution
Added
generateSample()method toSampleURIGeneratorthat creates valid sample strings from regex patterns:[a-z]→ uses the first valid character{n},+,*,?→ repeats accordingly.→ usesa\d→ uses the escaped charThis handles common regex patterns like
[A-Z]{3}[0-9]+,[a-f0-9]{8}, etc.Changes
One file:
system/Commands/Utilities/Routes/SampleURIGenerator.php::unknown::fallback withgenerateSample($regex)generateSample()private methodTesting
[A-Z]{3}[0-9]+→ generatesAAA0✓:num→ continues using predefined123✓:any→ continues using predefined123/abc✓Ref: https://github.com/codeigniter4/CodeIgniter4/issues/9804
Closes #9804