-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reject invalid URIs in URI extract functions #18253
Conversation
It's not by (any document) design to silently ignore invalid input in URI extracting functions (url_extract_fragment, url_extract_host, url_extract_parameter, url_extract_path, url_extract_port, url_extract_protocol, url_extract_query). This commit follows least surprise principle: invalid input is explicitly rejected. Users wanting to ignore invalid input should use `try(...)` expression around the invocations. This commit does not change docs, since now the functions behave as documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
% comment
|
||
assertTrinoExceptionThrownBy(() -> assertions.function("url_extract_fragment", "'" + url + "'").evaluate()) | ||
.hasErrorCode(INVALID_FUNCTION_ARGUMENT) | ||
.hasMessageStartingWith("Cannot parse as URI value '%s': ".formatted(url)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test also try(url_extract_fragment(...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we should be testing try
in TestUrlFunctions.java
CI #17436 |
Actually, it was by design. It's not an accident that the implementations were doing This is a backward incompatible language change that deserves more careful consideration, and possibly a migration path that allows restoring the legacy behavior. |
It's not by (any document) design to silently ignore invalid input in URI extracting functions (url_extract_fragment, url_extract_host, url_extract_parameter, url_extract_path, url_extract_port, url_extract_protocol, url_extract_query).
This commit follows least surprise principle: invalid input is explicitly rejected. Users wanting to ignore invalid input should use
try(...)
expression around the invocations.This commit does not change docs, since now the functions behave as documented.
Release notes
(x) Release notes are required, with the following suggested text: