Merged
Conversation
GitLab Pipeline ActionGeneral informationLink to pipeline: https://gitlab.com/code0-tech/development/draco/-/pipelines/2463762238 Status: Passed Job summariesdocs:previewDocumentation preview available at https://code0-tech.gitlab.io/-/development/telescopium/-/jobs/13989243933/artifacts/out/index.html |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reworks REST adapter flow identification to prevent accidental URL matches by anchoring the configured URL regex and improving observability around route matching (resolving #207).
Changes:
- Refactors
RequestRoute::identifyto use a helper for extracting string flow settings and adds structured debug logs for rejection reasons. - Introduces
matches_route_patternto anchor the route regex (^...$) to avoid substring matches. - Adds unit tests for the anchored matching helper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
+70
| let route_pattern = format!("/{}{}", flow.project_slug, flow_http_url); | ||
| log::debug!( | ||
| "Comparing regex {} with literal route: {}", | ||
| regex_str, | ||
| "route identify route check: flow_id={} httpURL={:?} resolved_pattern={:?} request_path={:?}", | ||
| flow.flow_id, | ||
| flow_http_url, | ||
| route_pattern, | ||
| self.url | ||
| ); | ||
|
|
||
| // Check if the request is matching | ||
| match regex::Regex::new(regex_str) { | ||
| Ok(regex) => { | ||
| log::debug!("Successfully compiled regex: {}", regex_str); | ||
| regex.is_match(&self.url) | ||
| } | ||
| Err(err) => { | ||
| log::error!("Failed to compile regex: {}", err); | ||
| false | ||
| } | ||
| } | ||
| let is_match = matches_route_pattern(&route_pattern, &self.url); | ||
| log::debug!( | ||
| "route identify result: flow_id={} matched={}", | ||
| flow.flow_id, | ||
| is_match | ||
| ); | ||
| is_match |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves: #207