Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/quackapi_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4114,6 +4114,21 @@ void QuackapiHttpServer::HandleRequest(const duckdb_httplib::Request &req, duckd
raw = it->second.second;
}

// Client bytes are not guaranteed valid UTF-8 (query/form/header/
// cookie decoders pass bytes through). DuckDB's Value(string)
// throws Invalid Input on invalid UTF-8, which would otherwise
// escape as a 500 with a serialized-exception body. Probe once
// here so malformed bytes become a 422 on the parameter that
// carried them.
try {
Value utf8_probe(raw);
(void)utf8_probe;
} catch (std::exception &) {
validation_issues.push_back(
{ValidationLocJson(loc_kind, param_name), "Input should be valid UTF-8 text", "type_error"});
continue;
}

// Strict integral check even when type is UNKNOWN: if the raw value
// is number-like but not a strict integer, and a cast-to-int would
// succeed via DuckDB rounding (1.5→2, 1e2→100), reject now.
Expand Down
Loading