[9.3] [APM] Improve redirect with default date range guard (#256887)#257060
Merged
kibanamachine merged 1 commit intoelastic:9.3from Mar 11, 2026
Merged
[9.3] [APM] Improve redirect with default date range guard (#256887)#257060kibanamachine merged 1 commit intoelastic:9.3from
kibanamachine merged 1 commit intoelastic:9.3from
Conversation
## Summary Closes elastic#256735 This PR updates the RedirectWithDefaultDateRange guard in APM to improve how we handle invalid and unexpected values in time range parameters for URLs in APM that require said parameters. ## Root cause A fair amount of routes in APM require a time range to be defined in the query params of the url. Without them, the components rendered within this routes wouldn't work properly and would instead throw errors that would lead to a page crash. To avoid crashing because of this, the APM app route has a built in guard in one of the wrapping components `RedirectWithDefaultDateRange`. This component runs some validations internally to verify that the time range parameters (`rangeFrom` and `rangeTo`) are set. If any of the params are detected missing, the component stops the rendering tree (returns `null`) and performs a redirect ensuring the both parameters are set with defaults values in case they're missing. While this approach ensures a time range is set in case it is missing, it wasn't factoring in that the parameters could be present but have invalid values. Because up until now we were just checking that range parameters had a string value, but weren't validating the string content, the guard would allow rendering to continue but the unparseable value would still trigger an error in the components downstream, leading to a page crash. The changes introduced in this PR update the validation run in the guard component to verify not only that the parameters are set but also that their values are valid, parseable datemath expressions. If one of them (or both) aren't parseable, the redirect will be performed setting them to whatever the default value for them should be. This ensures that a valid time range is always available for components that expect it, both when the range is missing or when it is present but invalid ## Reproduction Navigate to the following path `app/apm/services?comparisonEnabled=true&environment=ENVIRONMENT_ALL&rangeFrom=invalid&rangeTo=invalid&offset=1d` verify how the page doesn't crash and the `rangeFrom` and `rangeTo` values are replaced with valid default values. Defaults depend on kibana settings, but the standard defaults are `rangeFrom=now-15m&rangeTo=now` ## Release note Fixes an issue in APM apps where the website would crash if invalid values were passed to rangeFrom and rangeTo query parameters in the URLs --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit 58d2002)
Contributor
|
Pinging @elastic/obs-presentation-team (Team:obs-presentation) |
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsTest FailuresMetrics [docs]Async chunks
|
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.
Backport
This will backport the following commits from
mainto9.3:Questions ?
Please refer to the Backport tool documentation