Skip to content

Fix putObject warning#2316

Open
benzekrimaha wants to merge 1 commit intodevelopment/2.14from
improvement/ZENKO-5128-fix-putObject-warning
Open

Fix putObject warning#2316
benzekrimaha wants to merge 1 commit intodevelopment/2.14from
improvement/ZENKO-5128-fix-putObject-warning

Conversation

@benzekrimaha
Copy link
Contributor

@benzekrimaha benzekrimaha commented Feb 10, 2026

Issue: ZENKO-5128

@bert-e
Copy link
Contributor

bert-e commented Feb 10, 2026

Hello benzekrimaha,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@benzekrimaha benzekrimaha force-pushed the improvement/ZENKO-5128-fix-putObject-warning branch from 4555ab4 to cf2aadd Compare February 10, 2026 16:04
This commit introduces a middleware to fix the PutObject warning that occurs when the content length is not provided.
This middleware checks for the presence of the content length header and sets it to 0 if it is missing or appropriately handles it, ensuring that the PutObject operation can proceed without warnings.
This ensures that the PutObject operation can proceed without warnings.
Issue: ZENKO-5128
@benzekrimaha benzekrimaha force-pushed the improvement/ZENKO-5128-fix-putObject-warning branch from 19ccb35 to 3fc5dc9 Compare February 16, 2026 08:46
@bert-e
Copy link
Contributor

bert-e commented Feb 16, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

@benzekrimaha benzekrimaha marked this pull request as ready for review February 16, 2026 10:59
@scality scality deleted a comment from bert-e Feb 16, 2026
});

const scalityS3Client = new S3Client({
function attachContentLengthMiddleware(client) {
Copy link
Contributor

@francoisferrand francoisferrand Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not clear why we need this middleware : it would be required to automatically compute the ContentLength from Body.... but in uploadSetup() you systematically set the value already (and conversely: if we already add this middleware, no point doing it as well in uploadSetup)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In uploadSetup it's setup when the body is empty only , this one is to avoid having to put the contentLength each time we call the method , the middleWare is called upon client creation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after checking => UploadSetup runs only in the CLI cucumber steps, so it has to inject contentLength (including the zero-byte PutObject fallback). The middleware sits on the Node SDK clients used by the node test suite, which never call uploadSetup, so it fills ContentLength there. Two separate harnesses, two helpers; both are needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second read : I understand we can't use the same "fix" as CTST, but I wonder if we have that many cases where adding the length is needed?

If it is only in a few places, would be much simpler to just update these few calls to make "correct" calls to the SDK v3. This may increase the length of the change (PutObjectCommand is used 36 times, though we may not need to fix them all), but it will have much lower cognitive complexity, and will avoid leaving incorrect code here which may be copy-pasted (to some other repo) and fail there. Especially since this is not seamless anyway, as the client must be created in some custom way.

client.middlewareStack.add(
(next, context) => async args => {
const input = args.input || {};
if (context?.commandName === 'PutObjectCommand'
Copy link
Contributor

@francoisferrand francoisferrand Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • why only PutObjectCommand ? why not as well put part ?
  • is it not the same logic as below, and just another kind of Body ?
Suggested change
if (context?.commandName === 'PutObjectCommand'
if (input.ContentLength !== undefined || context?.commandName !== 'PutObjectCommand') {
return next(args);
}
if (!input.Body) {
input.Body = '';
input.ContentLength = 0;
} else if (Buffer.isBuffer(input.Body)) {
input.ContentLength = input.Body.length;
} else [...]

Copy link
Contributor Author

@benzekrimaha benzekrimaha Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PutObject only guard is just for the case where a test creates an empty object without providing a body. In that situation the SDK can’t compute contentLength, so we synthesise both values before sending the command. Every other flow (including all UploadPart calls) already pass a real body, for which we calculate the payload's contentLength automatically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ok-ish for first question (maybe we don't go into that path, but it would not harm to handle it as well?)
  • suggestion for simplification still stands, code is nested and harder to read than it should...

@bert-e
Copy link
Contributor

bert-e commented Feb 16, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following reviewers are expecting changes from the author, or must review again:

@benzekrimaha benzekrimaha changed the title Improvement/zenko 5128 fix put object warning Fix putObject warning Feb 16, 2026
const input = args.input || {};
if (context?.commandName === 'PutObjectCommand'
&& (input.Body === undefined || input.Body === null)) {
input.Body = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure you need to modify body, I think we just need to have content length set to a value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only do so when it's undefined or null as an additionnal safety gate

Copy link
Contributor

@SylvainSenechal SylvainSenechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me but might be other less intrusive method than a global middleware, I think passing the value ContentLength: xx to all putObjectCommand could've fixed it. We have ~25 putObjectCommand in zenko test, but I think everytime, the content length is very well known in advance as an hardcoded value (or 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments