8000 Minor fixes to exception error messages by carlopi · Pull Request #17528 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Minor fixes to exception error messages #17528

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

Merged
merged 2 commits into from
May 19, 2025

Conversation

carlopi
Copy link
Contributor
@carlopi carlopi commented May 18, 2025

Minor, I bumped on those, they can be as well be fixed.

The fix at src/main/extension.cpp would need to be generalized, there might be other places where we construct exception messages from unsanitized strings, and while that is handled by Format function, then error that is then re-throw bumps to InternalError and it's not super clear.
My proposal would be to change exceptions to take a const char * instead of a string, so that string concatenation is forbidden while constant strings are still allowed.
But this requires changes in many places, and not a point fix.


Either v1.3-ossivalis or main, both are fine, this is minor.

@Mytherin
Copy link
Collaborator

The fix at src/main/extension.cpp would need to be generalized, there might be other places where we construct exception messages from unsanitized strings, and while that is handled by Format function, then error that is then re-throw bumps to InternalError and it's not super clear.

If a call to the exception constructor does not have any parameters we shouldn't call the format function at all, no? In ConstructMessage:

template <typename... ARGS>
static string ConstructMessage(const string &msg, ARGS... params) {
	const std::size_t num_args = sizeof...(ARGS);
	if (num_args == 0) {
		return msg;
	}
	std::vector<ExceptionFormatValue> values;
	return ConstructMessageRecursive(msg, values, params...);
}

This is only really a problem when mixing string addition and formatting.

@Mytherin Mytherin merged commit 4075e33 into duckdb:v1.3-ossivalis May 19, 2025
50 checks passed
@Mytherin
Copy link
Collaborator

Either way, thanks for the fixes!

@carlopi
Copy link
Contributor Author
carlopi commented May 19, 2025

You are right, I am not sure what I saw then, possibly the throw was elsewhere where indeed format + parameters are there.

@carlopi carlopi deleted the minor_fixes_exceptions branch May 19, 2025 07:14
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 21, 2025
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 21, 2025
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 21, 2025
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0