fix: correct KeyCount and IsTruncated semantics for ListObjects#4
Open
Amahdip wants to merge 2 commits into
Open
fix: correct KeyCount and IsTruncated semantics for ListObjects#4Amahdip wants to merge 2 commits into
Amahdip wants to merge 2 commits into
Conversation
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.
Description
This PR focuses strictly on a few correctness issues regarding the S3
ListObjectsAPIs (v1andv2), specifically addressing metadata accuracy (KeyCountandIsTruncated).Note: This PR does not attempt to fully implement S3 pagination (
NextMarker/NextContinuationToken). It intentionally leaves tokens empty to avoid promising incomplete/broken pagination to clients, keeping the scope narrow to metadata correctness.Changes Made:
ListObjectsV2,KeyCountis now dynamically calculated as the sum of emitted files (Contents) plus emitted directories (CommonPrefixes), instead of returning a hardcoded0.IsTruncatedwas incorrectly flagged. The loop now processes themax_keys + 1item. If the limit is reached and another valid, emit-able item exists, the loop halts without emitting it and accurately setsis_truncated = true. This handles edge cases where the files match exactlymax_keys.walker.skip_current_dir(). Since it was unconditionally applied to file entries (directories were filtered out earlier in the loop), it was a no-op that just created logical confusion.KeyCountandIsTruncatedbounds, including delimiter semantics.توضیحات فارسی
این PR به طور مشخص روی برطرف کردن باگهای مربوط به صحت متادیتا (مثل
KeyCountوIsTruncated) در API مربوط بهListObjectsتمرکز دارد و شامل پیادهسازی کامل سیستم صفحهبندی (Pagination) نیست. توکنهای بازگشتی موقتاً خالی گذاشته شدهاند تا به کلاینتها وعده صفحهبندی خراب داده نشود.تغییرات اعمال شده:
KeyCountاز این به بعد مجموع دقیقی از فایلها (Contents) و پوشههای بازگردانده شده (CommonPrefixes) است و دیگر عدد صفر به صورت هاردکد ارسال نمیشود.walker.skip_current_dir()حذف شد.