cleanup: replace "OK" string returns with void#230
Merged
currantw merged 25 commits intovalkey-io:mainfrom Mar 20, 2026
Merged
Conversation
…tring return removal - Add OkStringReturnTypeTests: reflection-based tests asserting affected methods return Task (void) - Add PreservationReturnTypeTests: reflection-based tests asserting unchanged methods retain original return types - Bug condition tests confirm defect: 14 failures show methods return Task<string> instead of Task - Preservation tests pass on unfixed code, establishing baseline to protect Signed-off-by: currantw <[email protected]>
…g, object?> - Replace all OK() helper calls with Cmd<string, object?> using _ => ValkeyValue.Null pattern - Remove unused OK() helper method from Request.cs - Affected files: Request.ScriptingCommands.cs, Request.ServerManagement.cs, Request.ConnectionManagement.cs, Request.HashCommands.cs, Request.HyperLogLogCommands.cs, Request.GenericCommands.cs - Internal cleanup: ClientSetName, HashSetAsync (HMSet), HyperLogLogMergeAsync, KeyRestoreAsync, KeyRestoreDateTimeAsync already consumed as void Signed-off-by: currantw <[email protected]>
- Update IScriptingAndFunctionBaseCommands: ScriptFlushAsync, ScriptKillAsync, FunctionFlushAsync - Update IScriptingAndFunctionStandaloneCommands: FunctionDeleteAsync, FunctionKillAsync, FunctionRestoreAsync - Update IScriptingAndFunctionClusterCommands: all cluster-routed scripting/function commands - Update IServerManagementCommands and IServerManagementClusterCommands: SelectAsync - Update XML doc comments and code examples to reflect void returns Signed-off-by: currantw <[email protected]>
…g> to Task - Update BaseClient.ScriptingCommands.cs: ScriptFlushAsync, ScriptKillAsync, FunctionFlushAsync - Update GlideClient.ScriptingCommands.cs: FunctionDeleteAsync, FunctionKillAsync, FunctionRestoreAsync - Update GlideClient.cs: SelectAsync - Update GlideClusterClient.cs: SelectAsync - Update GlideClusterClient.ScriptingCommands.cs: all cluster-routed void commands - Remove .ToClusterValue(route) calls for void cluster commands Signed-off-by: currantw <[email protected]>
- Remove Assert.Equal("OK", result) patterns from integration tests
- Update batch test expectations from "OK" to null for void commands
- Update CommandTests converter assertions to expect ValkeyValue.Null
- Update PreservationReturnTypeTests for Cmd<string, object?> builder types
Signed-off-by: currantw <[email protected]>
- Use collection expressions instead of .ToArray() (IDE0305) - Remove unnecessary using directive (IDE0005) - Replace TheoryData<MethodInfo> with inline Fact to fix xUnit1045 Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Return types are enforced at compile time by the client implementations. Reflection-based checks add no value beyond what the compiler already guarantees. Signed-off-by: currantw <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR removes non-informative "OK" success return values from several async commands by changing them from Task<string> / Task<ClusterValue<string>> to Task, and updates request builders and tests accordingly.
Changes:
- Updated multiple public command APIs (standalone + cluster) to return
Taskinstead of returning"OK". - Refactored internal request builders to drop the
OK()helper and useCmd<string, object?>converters that discard the server payload. - Updated unit/integration/batch tests and XML docs to match the new void-style semantics.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Valkey.Glide.UnitTests/CommandTests.cs | Updates converter assertions for commands that previously surfaced "OK". |
| tests/Valkey.Glide.IntegrationTests/StandaloneClientTests.cs | Removes "OK" assertions for SelectAsync. |
| tests/Valkey.Glide.IntegrationTests/SharedBatchTests.cs | Adjusts batch assertions for restore/void-style results. |
| tests/Valkey.Glide.IntegrationTests/ScriptingCommandTests.cs | Removes "OK" result handling for scripting/function management commands (standalone + cluster routes). |
| tests/Valkey.Glide.IntegrationTests/ClusterClientTests.cs | Removes "OK" assertion for cluster SelectAsync. |
| tests/Valkey.Glide.IntegrationTests/BatchTestUtils.cs | Updates expected batch results for SelectAsync. |
| sources/Valkey.Glide/Internals/Request.cs | Removes the unused OK() request helper. |
| sources/Valkey.Glide/Internals/Request.ServerManagement.cs | Changes Select request to discard "OK" response. |
| sources/Valkey.Glide/Internals/Request.ScriptingCommands.cs | Changes scripting/function management requests to discard "OK" response. |
| sources/Valkey.Glide/Internals/Request.HyperLogLogCommands.cs | Changes PFMERGE request to discard "OK" response. |
| sources/Valkey.Glide/Internals/Request.HashCommands.cs | Changes HMSET request to discard "OK" response. |
| sources/Valkey.Glide/Internals/Request.GenericCommands.cs | Changes RESTORE requests to discard "OK" response. |
| sources/Valkey.Glide/Internals/Request.ConnectionManagement.cs | Changes CLIENT SETNAME request to discard "OK" response. |
| sources/Valkey.Glide/GlideClusterClient.cs | Updates SelectAsync to return Task and discard "OK". |
| sources/Valkey.Glide/GlideClusterClient.ScriptingCommands.cs | Updates routed cluster scripting/function management APIs to return Task. |
| sources/Valkey.Glide/GlideClient.cs | Updates SelectAsync to return Task and discard "OK". |
| sources/Valkey.Glide/GlideClient.ScriptingCommands.cs | Updates standalone function management APIs to return Task. |
| sources/Valkey.Glide/BaseClient.ScriptingCommands.cs | Updates base scripting/function management APIs to return Task. |
| sources/Valkey.Glide/Commands/ITransactionCommands.cs | Doc/example consistency updates for task-returning APIs. |
| sources/Valkey.Glide/Commands/ITransactionClusterCommands.cs | Doc/example consistency updates for task-returning APIs. |
| sources/Valkey.Glide/Commands/ITransactionBaseCommands.cs | Doc formatting/returns tag update for WatchAsync. |
| sources/Valkey.Glide/Commands/IServerManagementCommands.cs | Changes SelectAsync to Task and updates docs. |
| sources/Valkey.Glide/Commands/IServerManagementClusterCommands.cs | Changes SelectAsync to Task and updates docs. |
| sources/Valkey.Glide/Commands/IScriptingAndFunctionStandaloneCommands.cs | Changes function management return types to Task and updates docs/examples. |
| sources/Valkey.Glide/Commands/IScriptingAndFunctionClusterCommands.cs | Changes routed scripting/function management return types to Task and updates docs/examples. |
| sources/Valkey.Glide/Commands/IScriptingAndFunctionBaseCommands.cs | Changes scripting/function management return types to Task and updates docs/examples. |
| sources/Valkey.Glide/Commands/IPubSubCommands.cs | Standardizes <returns> docs for task-returning APIs. |
| sources/Valkey.Glide/Commands/IPubSubClusterCommands.cs | Standardizes <returns> docs for task-returning APIs. |
| sources/Valkey.Glide/Commands/IListCommands.cs | Standardizes <returns> docs for task-returning APIs. |
| sources/Valkey.Glide/Commands/IHyperLogLogCommands.cs | Standardizes <returns> docs for task-returning APIs. |
| sources/Valkey.Glide/Commands/IHashCommands.cs | Standardizes <returns> docs and minor whitespace normalization. |
| sources/Valkey.Glide/Commands/IGenericBaseCommands.cs | Adds/standardizes <returns> docs for restore APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Returning Task is the async equivalent of void — documenting <returns> on these methods adds no information. Signed-off-by: currantw <[email protected]>
currantw
commented
Mar 19, 2026
…sterCommands Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
…o `error` now that all violations have been removed. Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Add a well-known ValkeyValue.Ok constant wrapping the string "OK", alongside Null and EmptyString, for batch result consistency. Signed-off-by: currantw <[email protected]>
Add a Void() helper in Request.cs that returns ValkeyValue.Ok for void commands, replacing the repeated Cmd<string, object?> pattern. Signed-off-by: currantw <[email protected]>
…() helper Replace all Cmd<string, object?> and Cmd<string, string> patterns for void commands with the Void() helper that returns ValkeyValue.Ok. Signed-off-by: currantw <[email protected]>
…ValkeyValue.Ok Update unit test assertions for void-command converters to expect ValkeyValue.Ok instead of ValkeyValue.Null or raw string "OK". Signed-off-by: currantw <[email protected]>
…lkeyValue.Ok Update expected values for void-command batch results in BatchTestUtils.cs and SharedBatchTests.cs. Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
currantw
commented
Mar 19, 2026
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
… error to suggestion Signed-off-by: currantw <[email protected]>
Revert changes to .editorconfig files and ChannelMessageQueue.cs/ValkeyKey.cs that were not intended as part of this PR. Signed-off-by: currantw <[email protected]>
currantw
commented
Mar 19, 2026
currantw
commented
Mar 19, 2026
xShinnRyuu
reviewed
Mar 19, 2026
… into currantw/remove-ok-string-returns
xShinnRyuu
approved these changes
Mar 20, 2026
jeremyprime
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several async methods returned
Task<string>where the only possible success value was"OK"— the"OK"string carries no information beyond "the operation succeeded," which is already conveyed by the task completing without throwing.This PR changes these methods to return
Task(void) instead. For cluster variants,Task<ClusterValue<string>>wrapping"OK"similarly becomesTask(void).Additionally, this PR introduces
ValkeyValue.Ok(convenient representation forValkeyValuewith "OK"). Batch operation return "OK", aligning with other Valkey GLIDE clients.Issue Link
⚪️ None
Features and Behaviour Changes
Task<string>with"OK"now returnTask(void).Task<ClusterValue<string>>with"OK"now returnTask(void).ValkeyValue.Okstatic property — wrapping the string"OK"(similar to existingNullandEmptyString).Ok()request builder helper inRequest.csthat returnsValkeyValue.Ok.Ok()helper, returningCmd<string, ValkeyValue>instead ofCmd<string, object?>orCmd<string, string>.ValkeyValue.Okfor void commands, maintaining compatibility with other Valkey GLIDE clients.Affected methods:
ScriptFlushAsyncScriptKillAsyncFunctionFlushAsyncFunctionDeleteAsyncFunctionKillAsyncFunctionRestoreAsyncSelectAsyncConfigResetStatisticsAsyncConfigRewriteAsyncConfigSetAsyncFlushAllDatabasesAsyncFlushDatabaseAsyncClientSetNameHashSetAsync(HMSet overload)HyperLogLogMergeAsync(both overloads)KeyRestoreAsyncKeyRestoreDateTimeAsyncListTrimAsyncListSetByIndexAsyncImplementation
The fix is applied across three layers:
ValkeyValue.Okconstant (abstract_APITypes/ValkeyValue.cs): Addedpublic static ValkeyValue Ok { get; } = new ValkeyValue("OK")alongsideNullandEmptyString.Cmd()helper and request builders (Internals/Request.cs,Internals/Request.*.cs): Added aOk(RequestType, GlideString[])helper that returnsCmd<string, ValkeyValue>with converter_ => ValkeyValue.Ok. All void-command request builders across 7 partial files now use this helper.Commands/I*.cs): Changed return types fromTask<string>/Task<ClusterValue<string>>toTask. Updated XML doc comments accordingly.BaseClient.*.cs,GlideClient.cs,GlideClient.ScriptingCommands.cs,GlideClusterClient.cs,GlideClusterClient.ScriptingCommands.cs): Changedreturn await Command(...)toawait Command(...). For cluster methods, removed.ToClusterValue(route)calls.StackExchange.Redis Compatibility:
ScriptFlushAsync,ScriptKillAsync,FunctionFlushAsync,FunctionDeleteAsync,FunctionKillAsync,FunctionRestoreAsync,SelectAsync) are not part of the StackExchange.Redis 2.8.58 API surface. The internal request builder changes actually improve SER alignment - previouslyHashSetAsync,HyperLogLogMergeAsync,ListSetByIndexAsync,ListTrimAsync, andKeyRestoreAsyncreturnedTaskin SER butTask<string>in Valkey GLIDE.ValkeyValueis an StackExchange.Redis-compatible API, this change is additive - it does not impact SER-compatibility.Limitations
⚪️ None
Testing
CommandTests.cs) to expectValkeyValue.Okinstead ofValkeyValue.Nullor raw"OK"stringsBatchTestUtils.cs: Updated expected values forConfigSetAsync,ConfigResetStatisticsAsync,SelectAsync,ListTrim,ListSetByIndex,HashSetSharedBatchTests.cs: UpdatedBatchDumpAndRestoreassertionScriptingCommandTests.csStandaloneClientTests.csClusterClientTests.cs✅ All unit and integration tests pass
Related Issues
⚪️ None
Checklist
This Pull Request is related to one issue.CHANGELOG.md,README.md,DEVELOPER.md, and other documentation files are updated.mainor releasemain, squash otherwise.