Skip to content

test(evaluator): exercise ResolveStringValue in concurrency test#1986

Open
anxkhn wants to merge 1 commit into
open-feature:mainfrom
anxkhn:test/fix-concurrent-resolvestring-case
Open

test(evaluator): exercise ResolveStringValue in concurrency test#1986
anxkhn wants to merge 1 commit into
open-feature:mainfrom
anxkhn:test/fix-concurrent-resolvestring-case

Conversation

@anxkhn

@anxkhn anxkhn commented Jul 5, 2026

Copy link
Copy Markdown

This PR

In TestFlagStateSafeForConcurrentReadWrites
(core/pkg/evaluator/json_test.go), the "Update_ResolveStringValue" case
does not resolve a string flag. It calls ResolveBooleanValue and passes
StaticStringValue (a variant value, "#CC0000") as the flag key, whereas
every sibling case calls its namesake resolver with the matching *Flag key
constant:

"Add_ResolveBooleanValue":    ResolveBooleanValue(..., StaticBoolFlag, nil)
"Update_ResolveStringValue":  ResolveBooleanValue(..., StaticStringValue, nil)  // wrong resolver + value used as key
"Delete_ResolveIntValue":     ResolveIntValue(..., StaticIntFlag, nil)
"Add_ResolveFloatValue":      ResolveFloatValue(..., StaticFloatFlag, nil)
"Update_ResolveObjectValue":  ResolveObjectValue(..., StaticObjectFlag, nil)

The resolving goroutine discards the result (_ = tt.flagResolution(...)) and
only surfaces data races and panics, so the mismatch passes silently. The net
effect is that ResolveStringValue is never driven under concurrent
read/write (the path this case is named for gets zero race coverage), while
ResolveBooleanValue is exercised twice.

This is a test-only change; no production code is touched.

What's changed

One line in the "Update_ResolveStringValue" case so it matches its name and
the sibling pattern:

- _, _, _, _, err := evaluator.ResolveBooleanValue(context.TODO(), "", StaticStringValue, nil)
+ _, _, _, _, err := evaluator.ResolveStringValue(context.TODO(), "", StaticStringFlag, nil)

StaticStringFlag ("staticStringFlag") is a real ENABLED string flag in
the test's flagConfig, so the corrected call resolves an existing flag and
now genuinely covers the string-resolve path concurrently with SetState.

Testing

cd core
go build ./...
go test -race -run '^TestFlagStateSafeForConcurrentReadWrites$' ./pkg/evaluator/...
go test -race -covermode=atomic -cover -short ./pkg/evaluator/...

All green under -race. golangci-lint (repo-pinned v2.7.2) reports 0 issues
on the package.

In TestFlagStateSafeForConcurrentReadWrites, the "Update_ResolveStringValue"
case called ResolveBooleanValue with StaticStringValue (a variant value)
passed as the flag key, instead of ResolveStringValue with the
StaticStringFlag key like every sibling case. Because the concurrent
goroutine discards the resolution result and only surfaces data races or
panics, the mismatch passed silently: ResolveStringValue was never driven
under concurrent read/write, while ResolveBooleanValue was exercised twice.

Call ResolveStringValue with StaticStringFlag so the case matches its name
and actually covers the string-resolve path concurrently with SetState.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
@anxkhn anxkhn requested review from a team as code owners July 5, 2026 09:22
@netlify

netlify Bot commented Jul 5, 2026

Copy link
Copy Markdown

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit 6fa9951
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/6a4a225502cc44000877d81c

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 5, 2026
@coderabbitai

coderabbitai Bot commented Jul 5, 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: Pro Plus

Run ID: 7e83f6f0-266c-4420-8e37-06108ae7f540

📥 Commits

Reviewing files that changed from the base of the PR and between d99a3e3 and 6fa9951.

📒 Files selected for processing (1)
  • core/pkg/evaluator/json_test.go

📝 Walkthrough

Walkthrough

A test case in the concurrency safety test suite is corrected to invoke ResolveStringValue with StaticStringFlag rather than the previously mismatched ResolveBooleanValue call with StaticStringValue.

Changes

Test fix

Layer / File(s) Summary
Fix resolver call in concurrent test case
core/pkg/evaluator/json_test.go
Corrects the "Update_ResolveStringValue" case to call ResolveStringValue with StaticStringFlag instead of the mismatched ResolveBooleanValue/StaticStringValue call.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the test-only change to exercise ResolveStringValue in the concurrency test.
Description check ✅ Passed The description accurately explains the same test fix and is directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2026

Copy link
Copy Markdown

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

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant