Avoid duplicate response headers on Elysia 1.4.18 and earlier - #972
Avoid duplicate response headers on Elysia 1.4.18 and earlier#972dktsudgg wants to merge 7 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
dahlia
left a comment
There was a problem hiding this comment.
Could you add a changelog entry to CHANGES.md? Thanks!
|
@dahlia I added a changelog entry! |
|
@dktsudgg Could you change the target of this pull request to |
dd52ce7 to
ab95f06
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
|
@dahlia I changed target branch to |
|
Could you rebase your commits on the latest |
9d0061a to
d58b040
Compare
|
Sorry, the fix I made on |
When a response has a body, the plugin returns the `response` object directly, so there is no need to copy the response's headers into Elysia's `set.headers`. Elysia already includes `response.headers` in the HTTP response on its own. In fact, on Elysia 1.4.18 and earlier, copying `response.headers` into `set.headers` and then returning the response causes the HTTP response headers to be duplicated. (This was fixed on Elysia's side in 1.4.19.) This change therefore moves the early return of the `response` object, for the case where a body exists, above the header copy so that the HTTP response headers are no longer duplicated. While this problem is partly due to the bug in Elysia 1.4.18 and earlier, this fix is expected to resolve it sufficiently, so it does not raise the project's minimum Elysia version, keeping the current Elysia version support range intact. Assisted-by: Claude Code:claude-fable-5
Assisted-by: Claude Code:claude-fable-5
76d87fc to
655f2dc
Compare
|
Sorry, and I found that I mistyped like |
CHANGES.md links the `fedify-dev#972` reference to the pull request URL, but the fragment declared no link URLs, so sacho compiled its default issue URL and `sacho check` reported the materialized changelog as out of sync. Add a front matter links block so the compiled entry matches CHANGES.md. Assisted-by: Claude Code:claude-fable-5
Hongdown 0.5.3 requires a blank line after the front matter closing delimiter while sacho's normal form forbids one, so a fragment with a links block cannot satisfy both checkers. Exclude changes.d/ from Hongdown as main already does, leaving the fragments to sacho alone. Assisted-by: Claude Code:claude-fable-5
|
I added two commits with AI assistance to make It looks like there is a real incompatibility between sacho and hongdown rather than a one-off formatting issue.
|

Fixes #970.
@fedify/elysia'sfedify()plugin copies the federation response headers intoset.headersand then returns the sameResponseobject.When the response has a body, that
Responsealready carries its own headers,so on Elysia 1.4.18 and earlier(where Elysia merges
set.headersinto the returned response by appending unconditionally) every response header ends up duplicated.(for example :
Content-Type: application/activity+json, application/activity+json)Elysia 1.4.19 changed the merge to skip headers the response already has, which masks the bug, but the package still supports Elysia
^1.3.6, so users on 1.4.18 and earlier receive malformed federation responses that a strict ActivityPub peer can reject.This change moves the early
return response(the case where the response has a body) above the header copy,so the copy only runs on the bodyless path where a fresh
new Response(null, …)needs the headers.When there is a body the
Responseis returned untouched, so there is nothing for Elysia to merge back in, and the headers are no longer duplicated on any Elysia version.See #970 for the details.
Assisted-by: Claude Code:claude-fable-5