Skip to content

BUG: Remove nullability from attribute properties #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 28, 2022

Conversation

gliljas
Copy link
Contributor

@gliljas gliljas commented Jul 8, 2022

As mentioned in #175, attributes can't have nullable properties. It doesn't compile. It seems you haven't tested it.
That PR used nullable backing fields and GetOrDefault to retrieve them. I think that may actually be better for the future, enabling properties to be set in different levels, but here I took the easy route.

Also note that the default RequestTimeoutMs in this library is 5000ms, whereas in the Confluent library, if not set, it's 30000ms. Since it was impossible to specify RequestTimeoutMs before this fix, this would actually mean that we're changing from 30000 to 5000 now. The documentation for Confluent's MessageSendMaxRetries claims that the default is int.MaxValue, but I doubt that's the truth. confluentinc/confluent-kafka-dotnet#1858

Edit: It was the truth


/// <summary>
/// How many times to retry sending a failing Message. **Note:** default: 2
/// </summary>
/// <remarks>Retrying may cause reordering unless <c>EnableIdempotence</c> is set to <c>true</c>.</remarks>
public int? MaxRetries { get; set; }
public int MaxRetries { get; set; } = 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

int.MaxValue

@gliljas
Copy link
Contributor Author

gliljas commented Aug 30, 2022

@shrohilla I would really appreciate a bit of feedback on a bunch of PR:s. This one is a very clear bug that was reported more than 2 years ago.

@gliljas gliljas mentioned this pull request Nov 4, 2022
@shrohilla
Copy link
Contributor

@gliljas could you please explain more details about this PR, is default value is not being reflected for all attributes or is this only for int max value is assigned to MaxRetries attribute on startup ??

@gliljas
Copy link
Contributor Author

gliljas commented Nov 6, 2022

The PR is about having nullable properties on attributes, i.e MaxMessageBytes, BatchSize, EnableIdempotence, MessageTimeoutMs, RequestTimeoutMs or MaxRetries. It's not allowed. Your code will not compile if you use any of these properties.

@shrohilla
Copy link
Contributor

@gliljas could you please share the sample code where you found there was code compilation issue with functions ??
As per my understanding, the default value should be assigned to these properties if they are not set

@gliljas
Copy link
Contributor Author

gliljas commented Nov 7, 2022

Well, basically you could just try to use any of the mentioned properties yourself, and you'll see that it doesn't work.
Attribute property values must be compilable to constants. Nullables aren't.

https://dotnetfiddle.net/w5NrwO

@shrohilla shrohilla requested review from shrohilla and krishna-kariya and removed request for krishna-kariya November 7, 2022 12:47
@shrohilla
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@shrohilla
Copy link
Contributor

@gliljas Thanks alot for your contribution.
There is also regression with the change, I would request you to please fix that.

I'll also request you to please add 1 or 2 E2E tests with the change for both E2E and Lang E2E for testing the regression.

@gliljas
Copy link
Contributor Author

gliljas commented Nov 7, 2022

I doubt assigning the default values only will work.

That is not what the code does. The property types have changed. The end result is that the Confluent library will always be populated with the default values specified here, instead of Confluent's default values, so they have to be specified. In the case of MaxRetries, there is a difference, since Confluent specified int.MaxValue but this library specifies 2.

Another option, which I used in a PR two years ago is to use nullable backingfields, which will only get a value if they're specifically set.

@gliljas
Copy link
Contributor Author

gliljas commented Nov 7, 2022

I'll check the regression first.

@shrohilla
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@shrohilla
Copy link
Contributor

@gliljas I would request you to add 1 End to End test case to validate the flow

@shrohilla
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@gliljas
Copy link
Contributor Author

gliljas commented Nov 9, 2022

Sure thing, but any suggestion what such a test would do and assert? :)

@shrohilla
Copy link
Contributor

Sure thing, but any suggestion what such a test would do and assert? :)

One way could be try to re ingest the same event using the output binding after enabling idempotency than producer will not allow to re-ingest the same event and throw the error, that error you need to read from the log -- https://github.com/Azure/azure-functions-kafka-extension/blob/dev/test/Microsoft.Azure.WebJobs.Extensions.Kafka.EndToEndTests/TestLoggerProvider.cs#L42

Please share the feedback if this proposal doesn't works out.

@shrohilla
Copy link
Contributor

@gliljas any update on this ??

@gliljas
Copy link
Contributor Author

gliljas commented Nov 16, 2022

I'll get back to it tonight.

@shrohilla
Copy link
Contributor

@gliljas any update on this ??

@gliljas
Copy link
Contributor Author

gliljas commented Nov 25, 2022

Just making sure it was noted that an e2e test was added. Testing idempotency is a bit too hidden in Kafka to be triggered from the outside, so I chose MaxMessageBytes instead.

@shrohilla
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@shrohilla shrohilla left a comment

Choose a reason for hiding this comment

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

LGTM

@shrohilla
Copy link
Contributor

@gliljas Thanks alot for your contribution we will plan this change in next release.

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.

2 participants