Skip to content

Breaking change: Skip null values for form, header and query parameters#90

Merged
twogood merged 5 commits intomainfrom
copilot/fix-89
Aug 6, 2025
Merged

Breaking change: Skip null values for form, header and query parameters#90
twogood merged 5 commits intomainfrom
copilot/fix-89

Conversation

Copy link
Contributor

Copilot AI commented Aug 4, 2025

This PR implements a breaking change where null values for QueryParamAttribute, FormParamAttribute, and HeaderParamAttribute are completely skipped instead of being converted to empty strings.

Changes Made

Modified RequestHandler.GetParams() to add null checks before adding parameters:

// Before: null values were converted to empty strings and added
else
{
    queryParams.Add(Uri.EscapeDataString(queryParamAttribute.Name ?? parameterName) + "=" +
                    Uri.EscapeDataString(stringValue)); // stringValue was ""
}

// After: null values are completely skipped
else if (rawValue != null) // Skip null values
{
    queryParams.Add(Uri.EscapeDataString(queryParamAttribute.Name ?? parameterName) + "=" +
                    Uri.EscapeDataString(stringValue));
}

Breaking Change Behavior

Before this change:

[Get("api/users")]
Task GetUsers([QueryParam] string filter); // null becomes ?filter=

After this change:

[Get("api/users")]
Task GetUsers([QueryParam] string filter); // null parameter is completely omitted

What's Preserved

  • ✅ Empty strings ("") are still added as parameters
  • ✅ Dictionary parameter handling already worked correctly
  • ✅ All existing non-null parameter functionality
  • ✅ Backwards compatibility for all non-null values

Use Cases

If you want an empty parameter value, explicitly pass an empty string:

await client.GetUsers(""); // Results in ?filter=
await client.GetUsers(null); // Results in no filter parameter

This change affects all three parameter types: QueryParamAttribute, FormParamAttribute, and HeaderParamAttribute.

Fixes #89.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Breaking change: null values for form, header and query parameters should skip adding that parameter Breaking change: Skip null values for form, header and query parameters Aug 4, 2025
Copilot AI requested a review from twogood August 4, 2025 17:40
@twogood twogood marked this pull request as ready for review August 6, 2025 08:58
@twogood twogood requested a review from Copilot August 6, 2025 09:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a breaking change to skip null values for query, form, and header parameters instead of converting them to empty strings. The change affects QueryParamAttribute, FormParamAttribute, and HeaderParamAttribute handling in the RequestHandler.GetParams() method.

Key changes:

  • Modified parameter processing logic to skip null values entirely
  • Updated dictionary parameter handling to use explicit null checks
  • Added comprehensive test coverage for null parameter scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
Activout.RestClient/Implementation/RequestHandler.cs Modified GetParams() method to skip null values for all parameter types and updated dictionary handling with explicit null checks
Activout.RestClient.Test/NullParameterTests.cs Added comprehensive test suite covering null parameter handling for query, form, and header parameters
Activout.RestClient.Test/DictionaryParameterTests.cs Updated existing tests to use WithExactQueryString and adjusted expectations for null value handling

@twogood twogood merged commit 331dd57 into main Aug 6, 2025
8 checks passed
@twogood twogood deleted the copilot/fix-89 branch August 6, 2025 09:12
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.

Breaking change: null values for form, header and query parameters should skip adding that parameter

3 participants