Repository navigation
fix: empty Buffer for 0-byte reads, real CephError from normalize() - #13
Merged
Merged
Conversation
The OSD reads to the end of the object for a length of 0, which does not fit the empty buffer, so librados failed the read with ERANGE. A read of 0 bytes now only checks that the object exists with rados_stat: it resolves with an empty Buffer, and still fails with ENOENT for a missing object. Fixes #8 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CephError[Symbol.hasInstance] matches any object with a numeric code and a string operation, so normalize() returned such objects unchanged and its errno fallback never ran. It now checks the prototype chain, so an error-like object becomes a CephError with errno filled in from code and the original as its cause, while a real CephError is still returned as is. Fixes #9 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 1.2.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
What and why
Fixes #8 and #9, one commit each.
#8:
IoContext.read(oid, 0n)failed with ERANGE. The OSD treats a length of 0 as "read to the end of the object", which doesn't fit the empty buffer. A read of 0 bytes now checks that the object exists withrados_statinstead of reading it:RbdImage.read(offset, 0n)already returned an empty Buffer and is unchanged.#9:
CephError.normalize()returned error-like objects unchanged.CephError[Symbol.hasInstance]matches any object with a numericcodeand a stringoperation, so theinstanceofcheck at the top ofnormalize()always returned early. It now checks the real prototype chain:CephError, witherrnotaken fromcodeand the original kept ascause;CephErroris still returned unchanged.normalize()isn't used inside the library, so only callers of the public method see the difference.How it was tested
The new tests ran against both trees in the test cluster (Ceph Squid 19.2.7):
maina read of 0 bytes returns an empty Buffer, or ENOENT for a missing objectnormalize() turns error-like objects into a CephError and keeps real onesOn the branch the full suite passes (15/15), with no build warnings, and the coverage check passes (
rados_statwas already listed).Checklist
npm run check,npm test(with the integration suite) andnpm run coverage:apipasscoverage/api.json(none new)IoContextusein_flight(state_)!in the title (none)🤖 Generated with Claude Code