Skip to content
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

Fixing ArgumentNullException on empty select/expand #621

Merged
merged 1 commit into from
Jul 14, 2022

Conversation

giulianob
Copy link
Contributor

Fixes #620

@@ -82,33 +82,19 @@ public class SelectExpandQueryOption

// This constructor is intended for unit testing only.
internal SelectExpandQueryOption(string select, string expand, ODataQueryContext context)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Combined the testing and production constructors. The production constructor was never tested and the logic was not exactly the same.

@corranrogue9
Copy link
Contributor

I don't think the URLs that this allows are "legal" according to the ABNF (search for "$select"). I could be misreading it, or maybe something else you're aware of in the standard overrides it?

@giulianob
Copy link
Contributor Author

What should the behavior be? Return a 400? An internal server error should still be a bug IMO

@corranrogue9
Copy link
Contributor

Good point Giuliano, we triaged this today. $select= is not valid, so it should still be an error, but we agree with you that it should be 4xx instead of 5xx. From what I see in your tests, this PR makes it a 2xx? Would you be willing to make the change to change this to 4xx?

@giulianob
Copy link
Contributor Author

@corranrogue9 Fixed

image


private static void ValidateNotEmptyOrWhitespace(string rawValue)
{
if (rawValue != null && string.IsNullOrWhiteSpace(rawValue))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually pretty baffled that there's no existing string.IsWhiteSpace method. To double check, though, that's what you're trying to do here, right?

Any consideration for removing rawValue != null since that's already checked by both callers?

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.

Empty $select/$expand throws ArgumentNullException
3 participants