Repository navigation
Reject pixels without an access token before any request is made - #17
Merged
Merged
Conversation
For a pixel without an access token the client sent the request anyway:
http_build_query() drops the null value, so the POST carried no
access_token at all, and Meta answered with an error that does not
mention the token ("Unsupported post request. Object with ID ... does
not exist, cannot be loaded due to missing permissions ..."). With
several pixels, the ones listed before the token-less pixel had already
received the event when the exception was thrown.
PreparedEvent::withoutAccessTokens() makes token-less pixels a normal
state, and withAccessTokens() leaves pixels alone that are missing from
the list, so forgetting the call or a pixel id leads straight to this.
sendPreparedEvent(), and with it sendEvent(), now checks all pixels
first and throws a ClientException naming the pixels without an access
token. No request is made, so the event is never delivered to only some
of its pixels. An empty string counts as missing, since the property is
public and only the constructor normalizes it to null.
6 tasks done
loevgaard
added a commit
that referenced
this pull request
Sep 21, 2026
…ent (#19) Since #17 a single pixel without an access token made the client throw before sending anything, so that one pixel kept every other pixel from receiving the event. A pixel without an access token is a legitimate state, a pixel that is only used in the browser for instance. The client now sends to every pixel that has an access token, skips the ones that do not, and logs an error naming them. It throws an InvalidArgumentException only when none of the pixels has an access token, which is what happens when PreparedEvent::withAccessTokens() is forgotten after withoutAccessTokens().
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.
Summary
Posting to Meta without an access token can never succeed, yet the client did it anyway.
What happened before
http_build_query()drops null values, so for a token-less pixel the POST carried onlydata=…, with noaccess_tokenfield at all.2.0 makes this more likely:
PreparedEvent::withoutAccessTokens()turns token-less pixels into a normal state, andwithAccessTokens()deliberately leaves pixels alone that are missing from the list. Forgetting the call, or a pixel id, led straight to the above.What happens now
sendPreparedEvent(), and with itsendEvent(), checks all pixels first and throwsClientException::missingAccessToken()naming the pixels, with a hint atwithAccessTokens(). No request is made, so the event is never delivered to only some of its pixels. An empty string counts as missing, becausePixel::$accessTokenis public and only the constructor normalizes''to null.Token-less pixels are skipped nowhere and nothing is logged-and-dropped: a token-less pixel is legitimate for browser-only use with
FbqGenerator, so the client cannot tell "not meant for the server" from "forgot to restore the token", and silently losing conversions is the worst failure mode for a tracking library. An exception lets a queue retry or park the message.Compatibility
No new BC break (Roave: none). The call already ended in a
ClientExceptionbefore, only later and with Meta's text. The one difference is documented inUPGRADE-2.0.md: with several pixels, those listed before the token-less one no longer receive the event.Two existing tests sent events with a token-less pixel and asserted a body without
access_token; they now use a token.Docs
README (queue section and error handling), CLAUDE.md (client paragraph),
UPGRADE-2.0.md(new section), and the docblocks onClientInterfaceandPixel::$accessToken.Test plan
ClientTest::it_throws_when_a_pixel_has_no_access_token— message names the pixel, no request madeClientTest::it_sends_nothing_when_any_of_the_pixels_has_no_access_token— four pixels, two restored viawithAccessTokens(): the message lists exactly the other two, and not even the first, valid pixel receives the eventClientTest::it_treats_an_empty_access_token_as_missingClientExceptionTest::it_is_created_from_pixels_without_an_access_token— exact message2.x: no breaks