Skip to content

Fix SimpleStateCheckerManager overwriting result between batch checkers#25417

Merged
EngincanV merged 1 commit into
rel-10.4from
fix-state-checker-manager-result-overwrite
May 13, 2026
Merged

Fix SimpleStateCheckerManager overwriting result between batch checkers#25417
EngincanV merged 1 commit into
rel-10.4from
fix-state-checker-manager-result-overwrite

Conversation

@maliming

Copy link
Copy Markdown
Member

When a state has multiple batch checkers (e.g. RequirePermissions plus RequireFeatures), SimpleStateCheckerManager.IsEnabledAsync(TState[]) overwrites the per-state result on every checker pass, so a later true silently masks an earlier false. AND-combine the results so all checkers must pass.

This shows up in practice on menu items that chain .RequireFeatures(...).RequirePermissions(...) (e.g. Language management, Text templates, Audit logs): when a role grants the feature but not the permission, the menu item still becomes visible because the feature checker's true overwrites the permission checker's false.

Added regression tests under framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_AndCombineResults_Tests.cs covering false-then-true, true-then-false and all-true orderings. Reverse-verified: with the fix removed, the false-then-true test fails.

When a state has multiple batch checkers (e.g. RequirePermissions plus
RequireFeatures), the per-state result was overwritten on every checker
pass, so a later 'true' silently masked an earlier 'false'. AND-combine
the results to require all checkers to pass.
Copilot AI review requested due to automatic review settings May 13, 2026 03:13
@maliming maliming added this to the 10.4-final milestone May 13, 2026
@maliming maliming requested a review from EngincanV May 13, 2026 03:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an incorrect result aggregation in SimpleStateCheckerManager.IsEnabledAsync(TState[]) where per-state results from multiple batch checkers were previously overwritten instead of combined, allowing a later true to mask an earlier false. This aligns batch-checker behavior with the expected “all checkers must pass” (AND) semantics and prevents incorrect enablement/visibility decisions (e.g., menu items requiring both features and permissions).

Changes:

  • AND-combine per-state results across multiple batch state checkers (result[state] = result[state] && checkerResult).
  • Add regression tests covering false→true, true→false, and all-true batch-checker orderings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
framework/src/Volo.Abp.Core/Volo/Abp/SimpleStateChecking/SimpleStateCheckerManager.cs Fixes batch-checker aggregation to AND-combine results instead of overwriting.
framework/test/Volo.Abp.Core.Tests/Volo/Abp/SimpleStateChecking/SimpleStateChecker_AndCombineResults_Tests.cs Adds regression tests validating correct aggregation across multiple batch checkers and ordering scenarios.

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 2.00000% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.30%. Comparing base (a7c0826) to head (b982334).
⚠️ Report is 20 commits behind head on rel-10.4.

Files with missing lines Patch % Lines
...king/SimpleStateChecker_AndCombineResults_Tests.cs 0.00% 49 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           rel-10.4   #25417      +/-   ##
============================================
- Coverage     49.32%   49.30%   -0.03%     
============================================
  Files          3667     3668       +1     
  Lines        123186   123235      +49     
  Branches       9409     9412       +3     
============================================
- Hits          60765    60757       -8     
- Misses        60596    60666      +70     
+ Partials       1825     1812      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EngincanV EngincanV merged commit 0e0e735 into rel-10.4 May 13, 2026
6 of 8 checks passed
@EngincanV EngincanV deleted the fix-state-checker-manager-result-overwrite branch May 13, 2026 06:27
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.

3 participants