Skip to content

Fixing ArgumentNullException on empty select/expand - #621

Merged
Nthemba merged 1 commit into
OData:mainfrom
giulianob:empty-select-expand
Jul 14, 2022
Merged

Fixing ArgumentNullException on empty select/expand#621
Nthemba merged 1 commit into
OData:mainfrom
giulianob:empty-select-expand

Conversation

@giulianob

Copy link
Copy Markdown
Contributor

Fixes #620

@@ -82,33 +82,19 @@ internal SelectExpandQueryOption(

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@corranrogue9

Copy link
Copy Markdown
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
giulianob force-pushed the empty-select-expand branch from 5358306 to f3443d8 Compare June 27, 2022 17:33
@giulianob

Copy link
Copy Markdown
Contributor Author

@corranrogue9 Fixed

image


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

Copy link
Copy Markdown
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