fix(collect): Fix the issue where referer might be null#4043
Open
God-2077 wants to merge 2 commits into
Open
Conversation
Handle the case where the referer header could be null, and uniformly use the value from either the referer or referrer header.
|
@God-2077 is attempting to deploy a commit to the umami-software Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Greptile SummaryThis PR fixes a null-safety issue where
Confidence Score: 1/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant CollectRoute as /p or /q Route
participant SendAPI as POST /api/send
participant Zod as Zod Schema
participant DB as Database
Browser->>CollectRoute: GET /p/:slug or /q/:slug
Note over CollectRoute: Gets referer header (may be null)
CollectRoute->>CollectRoute: Build payload with { referer } ❌
Note over CollectRoute: Field named "referer" instead of "referrer"
CollectRoute->>SendAPI: POST with payload
SendAPI->>Zod: safeParse(body)
Note over Zod: Schema expects "referrer" field<br/>Unknown key "referer" is stripped
Zod-->>SendAPI: Parsed data (referrer = undefined)
SendAPI->>DB: saveEvent (referrerPath = undefined)
Note over DB: Referer data lost silently
Last reviewed commit: 920b81d |
ccc2fbc to
0640862
Compare
vdmsmnk
added a commit
to vdmsmnk/umami
that referenced
this pull request
Mar 18, 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.
Handle the case where the referer header could be null, and uniformly use the value from either the referer or referrer header.
#4038