Skip to content

Unable to specify scope on EnsureFeaturesAreActive middleware #145

@samdharris

Description

@samdharris

Pennant Version

v1.18.0

Laravel Version

v12.21.0

PHP Version

8.3

Database Driver & Version

MYSQL 8.0.41

Description

We have some feature flags scoped to an organisation and then some that are null scoped so they apply system-wide. We call resolveScopeUsing to default the scope to the current user's organisation. However, when using the EnsureFeaturesAreActive middleware it is currently not possible to specify the scope we want to use. This causes the error "Argument #1 ($scope) must be of type null, App\Models\Organisation given".

Steps To Reproduce

Have a feature with the null scope and have another scoped to the Organisation model. in AppServiceProvider call Feature::resolveScopeUsing(fn ($driver) => auth()->user()?->organisation);.

Define a route that you want to be behind the null scoped feature flag and have one that is flagged behind the organisation. Use the EnsureFeaturesAreActive middleware and visit the route while authenticated.

**Expected Result: ** The route behind the null scoped feature flag should be visitable if the flag is enabled and the route behind the organisation scoped feature should also be visitable if the flag is enabeld.

Current When authenticated the null scoped feature flag errors Argument #1 ($scope) must be of type null, App\Models\Organisation given

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions