Skip to content

IBX-12192: Skip SiteAccessStamp for uninitialized SiteAccess - #27

Merged
Steveb-p merged 3 commits into
4.6from
IBX-12192-skip-siteaccess-stamp-when-uninitialized
Aug 4, 2026
Merged

IBX-12192: Skip SiteAccessStamp for uninitialized SiteAccess#27
Steveb-p merged 3 commits into
4.6from
IBX-12192-skip-siteaccess-stamp-when-uninitialized

Conversation

@Steveb-p

@Steveb-p Steveb-p commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-12192

Related PRs:

Description:

SendMessageSiteAccessSubscriber only skipped stamping when SiteAccessServiceInterface::getCurrent() returned null. Turns out that's not what happens when a message gets dispatched from a context where no HTTP request ever matched a SiteAccess — e.g. a console command. getCurrent() instead returns the placeholder SiteAccess CoreBundle wires into the container before request matching (name default, matchingType = 'uninitialized'), so the subscriber stamped the envelope with that. On the consuming side, SiteAccessMiddleware then tried to resolve a SiteAccess literally named 'default' and blew up with NotFoundException: Could not find 'SiteAccess' with identifier 'default'.

This is what broke ibexa/data-intelligence-layer's CI, which dispatches messages from console-driven integration tests (failing run).

Fix mirrors the existing null check: skip stamping when $siteAccess->matchingType === SiteAccess::MATCHING_TYPE_UNINITIALIZED.

SendMessageSiteAccessSubscriber only skipped stamping when
SiteAccessServiceInterface::getCurrent() returned null. When a message
is dispatched from a context with no matched SiteAccess (e.g. a
console command), getCurrent() instead returns the placeholder
SiteAccess with matchingType 'uninitialized', which got stamped and
later failed to resolve on the consumer side.
Points CI at the ibexa/core branch that adds SiteAccess::MATCHING_TYPE_UNINITIALIZED,
so this PR's tests can run before that PR merges. Must be removed before merging.
@mnocon

mnocon commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

I'm not sure I understand the description correctly, and just want to clarify:

I've always thought that when you don't specify the siteaccess with the command (the --siteaccess) option, the default siteaccess is used.

From the --siteaccess help description:

php bin/console cache:clear --help
#...
--siteaccess[=SITEACCESS]  SiteAccess to use for operations. If not provided, default siteaccess will be used

And by default siteaccess I mean the default_siteaccess setting:https://github.com/ibexa/recipes-dev/blob/master/ibexa/oss/4.6/config/packages/ibexa.yaml#L64

I didn't know that by omitting the option the siteaccess is not set at all (that's how I understand "uninitialized").
Can it affect the processing at all, compared to what would have happened if the default siteaccess was set?

I mean, can you get different results by running:

php bin/console app:my-command
php bin/console app:my-command --siteaccess=site

?

@mnocon

mnocon commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Thinking about the following case:

Given the worker is run with:
php bin/console messenger:consume ibexa.messenger.transport --bus=ibexa.messenger.bus --siteaccess=site_B

When a command dispatching a message is invoked with:
php bin/console app:my-command

Result: SiteAccess is uninitialized -> no SiteAccessStamp, message is processed by the worker using the site_B context (default siteaccess for the worker)

When a command dispatching a message is invoked with:
php bin/console app:my-command --siteaccess=site

Result: SiteAccessStamp is attached, message is processed by the worker using the site siteaccess

ibexa/core#796 merged, so ibexa/core's ~4.6.x-dev now resolves the
SiteAccess::MATCHING_TYPE_UNINITIALIZED constant on its own.
@Steveb-p
Steveb-p merged commit 0acdf15 into 4.6 Aug 4, 2026
17 checks passed
@Steveb-p

Steveb-p commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@mnocon I'll need to confirm this - there is some chance that default_siteaccess might work, and it wasn't working in tests in another package because there were missing dependencies / bundles.

But tbh it is very, very likely that what you are describing might also be bugged and default site access may not be set for the bin/console context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants