Skip to content

fix: resolve disabled flags without an error - #574

Merged
sahidvelji merged 2 commits into
open-feature:mainfrom
kripa-sindhu-007:fix/memprovider-disabled-reason
Sep 7, 2026
Merged

sahidvelji merged 2 commits into
open-feature:mainfrom
kripa-sindhu-007:fix/memprovider-disabled-reason

Conversation

@kripa-sindhu-007

Copy link
Copy Markdown
Member

This PR

  • drops the ResolutionError from InMemoryFlag.Resolve's disabled branch, so a disabled flag resolves to the default with reason DISABLED and no error
  • extends TestInMemoryProvider_Disabled with an error assertion and a client-level subtest

ProviderResolutionDetail.Error() is non-nil whenever a code is set, so Client.evaluate treated a disabled flag as abnormal execution, overwrote DisabledReason with ErrorReason and returned a GENERAL error to the caller:

value=false reason="ERROR" errorCode="GENERAL" errorMessage="flag is disabled"
err=error code: GENERAL: flag is disabled

After the fix, reason DISABLED, the default value, and no error.

Related Issues

Fixes #552

Notes

  • Dropping the ResolutionError is the whole fix. Resolve already returns defaultValue on that branch and genericResolve asserts it against itself, so the value and the reason come out right on their own.
  • The existing test disabled flag subtest asserts only Value and Reason, both of which are already correct at the provider level, so it passes unchanged before and after this change. I have added an error assertion to it, otherwise nothing in the suite would catch a regression here.
  • The client-level subtest is the one that matters, since the reason is overwritten in Client.evaluate and a provider-level assertion cannot observe that. It uses isolated.NewAPI() so the global singleton is left alone — this package's tests have not driven the client before, and I did not want to introduce shared provider state into them.
  • Worth recording for anyone reading the issue: the DISABLED scenarios cited there are in evaluation_v2.feature in the spec repo. This repo's test-harness submodule is the flagd harness, and e2e runs only evaluation.feature from it, which has no disabled-flag scenarios. So e2e does not cover this today, which is likely why it went unnoticed. The parity argument with the Java and JS in-memory providers, both of which return DISABLED with no error, is what the fix rests on.
  • One line outside the strict fix: the reason assertion's failure message printed ErrorReason as its expectation while checking DisabledReason. It is inside the block being changed, so I corrected it rather than leave a misleading message next to a new assertion. Happy to split it out if you would rather.
  • On sequencing with feat: support updating the in-memory provider's flag set #539: the test uses := throughout and never names memprovider.InMemoryProvider explicitly, so it survives whichever of the two merges first.

How to test

go test -tags testtools -race -count=1 -run 'TestInMemoryProvider_Disabled' ./openfeature/memprovider/

InMemoryFlag.Resolve attached a general resolution error to the disabled
branch. ProviderResolutionDetail.Error() is non-nil whenever a code is
set, so Client.evaluate treated a disabled flag as abnormal execution,
overwrote DisabledReason with ErrorReason and returned a GENERAL error.

Dropping the ResolutionError is the whole fix: Resolve already returns
defaultValue on that branch, and genericResolve asserts it against
itself, so the value and reason come out right on their own.

Extends TestInMemoryProvider_Disabled to assert no error, and adds a
client-level subtest, since the provider-level assertions cannot observe
the reason being overwritten. The subtest uses an isolated API instance
so the global singleton is untouched.

Fixes open-feature#552

Signed-off-by: Kripa Sindhu <[email protected]>
@kripa-sindhu-007
kripa-sindhu-007 requested review from a team as code owners September 7, 2026 15:25
@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 8f79bfb1-ee7e-4d7f-98a1-2bd0db6b539d

📥 Commits

Reviewing files that changed from the base of the PR and between a0892c2 and 55b9b5a.

📒 Files selected for processing (2)
  • openfeature/memprovider/in_memory_provider.go
  • openfeature/memprovider/in_memory_provider_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The disabled in-memory provider path no longer returns a general resolution error. Tests now verify the disabled reason and nil error through both direct provider evaluation and client evaluation.

Changes

Disabled flag resolution

Layer / File(s) Summary
Disabled resolution and client validation
openfeature/memprovider/in_memory_provider.go, openfeature/memprovider/in_memory_provider_test.go
The disabled path returns DisabledReason without a ResolutionError. Tests verify the nil error and client-level result with the default value.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to e09b0

Disabled in-memory flags now return their configured default with a DISABLED reason rather than an error, and the behavior is covered at both provider and client levels.

Suggested reviewers: sahidvelji, aepfli, erka, james-milligan, thomaspoignant

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: disabled flags resolve without a resolution error.
Description check ✅ Passed The description directly explains the disabled-flag error, the fix, the test coverage, and the expected behavior.
Linked Issues check ✅ Passed The changes satisfy issue #552 by removing the resolution error, preserving the default value and DISABLED reason, and adding provider-level and client-level assertions for no error.
Out of Scope Changes check ✅ Passed All changes support issue #552. The production change fixes disabled-flag resolution, and the added tests verify the required behavior without unrelated code changes.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.64%. Comparing base (fcc5227) to head (e09b082).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #574      +/-   ##
==========================================
+ Coverage   86.55%   86.64%   +0.08%     
==========================================
  Files          22       22              
  Lines        2135     2134       -1     
==========================================
+ Hits         1848     1849       +1     
+ Misses        242      241       -1     
+ Partials       45       44       -1     
Flag Coverage Δ
e2e 86.64% <100.00%> (+0.08%) ⬆️
unit 86.64% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@sahidvelji
sahidvelji enabled auto-merge (squash) September 7, 2026 18:00

@erka erka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @kripa-sindhu-007

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.

[BUG] memprovider: a disabled flag surfaces a GENERAL error instead of reason DISABLED

3 participants