Send each message's custom headers and credentials on pooled S3 connections #512
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #512"
general
weight: 0.35
pacmano1
Closes #511.
The File Writer fills in
${...}variables in S3 custom headers for every message, but the pooledS3Connectionkept the headers of the message that created the pool, so every later write sent the first message's values. Credentials had the same problem with Use Default Credential Provider Chain on: credentials taken from the message, such as${user}, stuck at the first message's (found by Jon in review).Change
FileDispatcher.send: after borrowing a connection, an S3 connection gets this message's headers.S3Connection: keeps the headers in its own field (setCustomHeaders). It starts with the ones it was created with, and returning it to the pool puts those back. Not inschemeProps, because every connection in a pool shares the first message'sS3SchemeProperties.FileSystemConnectionFactory.getPoolKey: the S3 key includes the username and password whenever they're set. It left them out whenever the default chain was on, butS3Connectionsigns with them whenever they're set. Credentials that are set still take priority over the default chain, as before. With the default chain on and none set, every message still shares one pool.Thread safety: Donkey clones the connector properties for each message, including a copy of the header map, and the pool hands a connection to one sender until it's returned, so the headers set on a borrowed connection belong to that sender's message.
Tests
FileDispatcherTest: two sends through one pooledS3Connectionwith a mocked S3 client, plain and with Write to Temporary File (the move uploads again), checkingx-test-idon each upload. Both fail on main (expected:<[dir/message.txt=1, dir/message.txt=2]> but was:<[dir/message.txt=1, dir/message.txt=1]>).S3ConnectionTest.testPassivateRestoresCustomHeaders: returning the connection to the pool puts back the headers it was created with.FileSystemConnectionFactoryTest: three S3 pool keys. Default chain on with credentials set fails on main (s3://@us-west-2); default chain off, and on with no credentials, give the same keys as before.How to verify
Headers need an S3 bucket and credentials the engine can use, for example
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKENandAWS_REGIONin the engine's environment, with Use Default Credential Provider Chain on.1. New channel: Channel Reader source; source transformer JavaScript step
$c('clinic', String(msg));; File Writer in S3 mode, S3 Bucket<bucket>/s3-headers, file name${message.messageId}.txt, template${message.rawData}; in Amazon S3 Advanced Settings, Custom HTTP Headersx-amz-meta-clinic=${clinic}andx-test-id=${message.messageId}.2. Deploy, then send
clinic Aandclinic B.3.
aws s3api head-object --bucket <bucket> --key s3-headers/2.txt --query Metadata- Before:
{"clinic": "clinic A", "x-test-id": "1"}- After:
{"clinic": "clinic B", "x-test-id": "2"}Credentials are easiest to see without AWS. Set
AWS_ENDPOINT_URL_S3in the engine's environment to an HTTP server that logs each request'sAuthorizationheader (it startsAWS4-HMAC-SHA256 Credential=<access key id>/) and answers 200.1. Same channel, but the transformer step is
var p = String(msg).split(','); $c('user', p[0]); $c('pass', p[1]);, and the File Writer's Username is${user}and Password${pass}, with Use Default Credential Provider Chain still on.2. Send
AKIAMSGONE,secretoneandAKIAMSGTWO,secrettwo.- Before: both PUTs are signed with
AKIAMSGONE.- After: the second is signed with
AKIAMSGTWO.Headers were live-tested against real S3 on Java 21 in October, on top of #506 (AWS SDK 2.55.12). Before:
2.txtcarried message 1's values, with Keep Connection Open on and off. After: every object carried its own message's values, with Keep Connection Open on and off, and with the destination queue on and 2 threads (6 messages).After the review changes, main and this branch were run side by side on Java 17 against a stand-in endpoint as above. On main, every message after the first carried message 1's headers with Keep Connection Open on and off, with 2 queue threads, and on both temporary file paths (anonymous re-upload, and the keyed server-side copy of the
.tmpupload), and credentials from the message stuck at message 1's. On this branch each message carried its own headers and was signed with its own credentials. Blank credentials used the default chain on both.Release Note
The File Writer now sends each message's S3 custom headers and credentials
With Amazon S3 selected, the File Writer reused the first message's custom HTTP headers for every later message while its connection stayed in the pool. A header such as
x-amz-meta-clinic=${clinic}was written with the first message's value on every object. The same happened to a username and password taken from the message when Use Default Credential Provider Chain was on: every message was signed with the first message's credentials.Each message is now written with its own headers and credentials. Channels that use the same headers and credentials for every message are not affected.
If the credentials are different for each message, the File Writer now keeps a separate pool of connections for each distinct username and password. These pools are released when the connector stops, so a channel with many distinct credentials will hold more connections than before. Other file schemes already behave this way.
Co-authored with Claude Code.