docs: fix incorrect code examples in Reply and Request reference#6582
Merged
mcollina merged 1 commit intofastify:mainfrom Mar 16, 2026
Merged
docs: fix incorrect code examples in Reply and Request reference#6582mcollina merged 1 commit intofastify:mainfrom
mcollina merged 1 commit intofastify:mainfrom
Conversation
- Replace non-existent `reply.getTrailer()` with `reply.hasTrailer()` in the removeTrailer example - Fix syntax errors in schema mutation examples where an extra dot before the assignment operator made the code invalid (`schema1.properties.foo.type. = 'integer'`)
jean-michelet
approved these changes
Mar 15, 2026
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
Fixed three incorrect code examples in the Reply and Request reference documentation:
Reply.mdline 311 —reply.getTrailer('server-timing')replaced withreply.hasTrailer('server-timing'). ThegetTrailer()method does not exist on the Reply prototype — onlytrailer(),hasTrailer(), andremoveTrailer()are implemented.Reply.mdline 499 — Fixed syntax errorschema1.properties.foo.type. = 'integer'(extra dot before assignment operator).Request.mdline 237 — Same syntax error fix as above in thecompileValidationSchemaexample.Why
While working with Fastify, I noticed the
removeTrailerexample references a non-existentgetTrailer()method, which would throw aTypeErrorat runtime if a user copied this code. The schema mutation examples also have a syntax error that would cause aSyntaxErrorif used directly.How
getTrailerdoes not exist inlib/reply.js— onlytrailer,hasTrailer, andremoveTrailerare definedhasTrailer()which correctly demonstrates verifying the trailer was removedChecklist
npm run unit— 2204 pass, 0 fail)npm run lintandnpm run lint:markdown)