Repository navigation
feat: Opt-in log of every DuckDB HTTP request (#252) - #258
Merged
Merged
Conversation
This was referenced Nov 24, 2026
- New test/integration/test_http_debug_log.py against a fake S3 holding the endpoint YAML, its SQL and eight CSV objects read via s3:// - Pins the line format `duckdb http <METHOD> <url> -> <status> <N>ms request_id=<id>`, one line per request the store served during the call, no credentials - Startup reads carry request_id=-; FLAPI_LOG_HTTP_REQUESTS=1 works like the key; JSON log format carries the same message - Switch off: no lines and the same I/O; 8 concurrent calls are not cross-attributed - RED today except the switch-off test
- Worker-thread scan (duckdb.threads: 4, nine objects incl. a multi-MB one): every line carries the request id - Presigned and user:password URLs, also with redact_http_logs=false in the connection init: no signature or password in any line - A 404 logs -> 404, a refused connection logs -> ERR - Remote --config fetch logged with request_id=- (bootstrap DuckDB) - FLAPI_LOG_HTTP_REQUESTS wins over log-http-requests, both directions - JSON: the record's request_id field is the request's id; text: exactly one request_id= per line; re-read after the expected count to catch duplicates
- New top-level key log-http-requests (default false), overridden in both directions by FLAPI_LOG_HTTP_REQUESTS; resolved before the endpoint files load, since a remote template.path is fetched while they do - DuckDBHttpLogSink (a duckdb::LogSink, synchronous, unbuffered) writes one info line per request: duckdb http <METHOD> <url> -> <status|ERR> <N>ms - The message is cast back to HTTPLogType's STRUCT with DuckDB's own cast, as duckdb_logs_parsed() does, instead of parsing its text - Attribution: QueryExecutor registers (database, connection id) -> request_id for each execution, so worker-thread scans carry the id; then the ambient request; then - - FlapiLogHandler::RequestIdOverride stamps that id once, as request_id= in text and the request_id field in JSON, held startup lines included - Enabled on the main database before any connection (and again after the connection init, forcing redact_http_logs=true) and on the bootstrap instance that reads a remote --config; off, DuckDB logging is untouched - URLs also go through PathSchemeUtils::RedactUrl, as a template can turn DuckDB's redaction off - Unit tests pinned to DuckDB 2.0.1's ConstructLogMessage output, the attribution guard under concurrency, and the log handler override - Integration test: the template fetches on /presigned and /dead are request lines too; filter to the data object
- OBSERVABILITY.md section 8 and env table, the component spec, CONFIG_REFERENCE key and env var, CHANGELOG Unreleased - flapi-operate skill and the flapi.yaml reference teach log-http-requests
- A template that sets redact_http_logs=false must still leak nothing:
jwt, one-letter and percent-encoded query keys, ';' separators,
colon-less userinfo with an '@' in the path, fragments
- RedactUrl: userinfo is what precedes the last '@' of the authority;
keys are matched percent-decoded; ';' separates
- URL bytes that could end a line or start a field are encoded, and the
text log format escapes CR/LF in every message
- A log entry that does not parse ('}' in the URL) still leaves an
attributed line
- The logged URL takes DuckDB's own redaction cut whatever redact_http_logs says: userinfo up to the last '@' of the authority and the fragment dropped, the whole query replaced by ?redacted; bytes < 0x21, >= 0x7f and '"' percent-encoded so the URL is one ASCII token - The text log format escapes CR/LF in every message - RedactUrl: RFC 3986 userinfo, percent-decoded keys, ';' separators, and jwt/hmac/session/ticket/bearer/assertion plus whole-key sid/code/pw - An entry that does not parse still logs 'duckdb http ? <unparsed> -> ?' with its request id (DuckDBHttpLogLineFor) - No exception leaves the sink (rate-limited warning); the sink returns before parsing when info is filtered out - Attribution: the thread's own request first, the connection map only on threads with none (ResolveHttpRequestId) - DatabaseManager reads ConfigManager::getLogHttpRequests(); ResetHttpRequestLogForTest(); the startup notice is a warning; comments on DuckDB's logger refresh corrected - Test corrections: the line has six spaces, not five; a '}' does not break DuckDB 2.0.1's STRUCT round trip (pinned), so the integration case checks the request is logged without its query; flAPI's generic error line, which quotes DuckDB's error text, is outside the field-forgery check
- Debugging only: path secrets are not redacted, parameters reach the log, synchronous writes under DuckDB's logging lock, volume grows with globs - What the URL keeps; worker-thread lines have no trace ids; on-demand vs scheduled cache refresh ids; includes need the env var; it takes over DuckDB's logging config and duckdb_logs; disable_logging turns it off - Azure unverified: its extension logs through the Azure SDK pipeline
jrosskopf
force-pushed
the
feat/gh-252-http-debug-log
branch
from
November 24, 2026 16:22
975b773 to
efb0f36
Compare
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.
Summary
log-http-requests: true(top level) orFLAPI_LOG_HTTP_REQUESTS=1(the env var wins). It writes one line into flAPI's log for each HTTP request DuckDB makes (S3, GCS, HTTP(S); Azure unverified):duckdb http GET <url> -> 200 12ms request_id=req-…. Reads made outside a request carryrequest_id=-.LogSink(src/duckdb_http_log_sink.*) is registered on the main DB and on the bootstrap DB, so the remote--configread is logged too.(DatabaseInstance*, connection_id)to request_id, set inQueryExecutor.redact_http_logsis set to.Red / green
SECRETJWT/SECRETSIG; forged lines and fields). The full failure lines are in the session notes.test_http_debug_log.py19/19, three runs in a row. Also green:test_remote_templates_s3(12) andtest_remote_templates(37)test_log_correlation,test_audit_*,test_tracing_error_trace_id,test_mcp_request_id,test_env_secrets_hygiene,test_health_stall_detectionflapi_tests1027/1028 (1 skipped) andcheck_skills --static-onlyNot in this PR
Error handling request:line quotes DuckDB's error text, URL included, so a space-separatedrequest_id=FAKEin a URL can look like a field there. Tracked separately.Test plan
Closes #252
🤖 Generated with Claude Code
https://claude.ai/code/session_018txuxF9jXyiKakpUoXrKBi
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.