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

Request with query string '=' returns 500 #1480

Closed
verdie-g opened this issue Feb 25, 2024 · 3 comments · Fixed by #1484
Closed

Request with query string '=' returns 500 #1480

verdie-g opened this issue Feb 25, 2024 · 3 comments · Fixed by #1484
Labels

Comments

@verdie-g
Copy link
Contributor

DESCRIPTION

curl 'http://localhost:5000/people?='

returns

{
  "links": {
    "self": "http://localhost:5065/people?="
  },
  "errors": [
    {
      "id": "76871a51-79fc-46ba-848b-f8027f5a03ed",
      "status": "500",
      "title": "An unhandled error occurred while processing this request.",
      "detail": "String cannot be null or empty. (Parameter 'parameterName')"
    }
  ]
}

STEPS TO REPRODUCE

  1. Follow https://www.jsonapi.net/getting-started/step-by-step.html
  2. Run curl 'http://localhost:5000/people?='

EXPECTED BEHAVIOR

A proper 4XX explaining the problem.

ACTUAL BEHAVIOR

A 500.

@verdie-g verdie-g added the bug label Feb 25, 2024
@bkoelman
Copy link
Member

What's the stack trace?

@verdie-g
Copy link
Contributor Author

System.ArgumentException: String cannot be null or empty. (Parameter 'parameterName')
         at void JsonApiDotNetCore.ArgumentGuard.NotNullNorEmpty(string value, string parameterName) in /_/src/JsonApiDotNetCore.Annotations/ArgumentGuard.cs:line 36
         at bool JsonApiDotNetCore.QueryStrings.FilterQueryStringParameterReader.CanRead(string parameterName) in /_/src/JsonApiDotNetCore/QueryStrings/FilterQueryStringParameterReader.cs:line 53
         at void JsonApiDotNetCore.QueryStrings.QueryStringReader.ReadAll(DisableQueryStringAttribute disableQueryStringAttribute)+(IQueryStringParameterReader nextReader) => { } in /_/src/JsonApiDotNetCore/QueryStrings/QueryStringReader.cs:line 41
         at TSource System.Linq.Enumerable.TryGetFirst<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
         at TSource System.Linq.Enumerable.FirstOrDefault<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate)
         at void JsonApiDotNetCore.QueryStrings.QueryStringReader.ReadAll(DisableQueryStringAttribute disableQueryStringAttribute) in /_/src/JsonApiDotNetCore/QueryStrings/QueryStringReader.cs:line 41
         at async Task JsonApiDotNetCore.Middleware.AsyncQueryStringActionFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) in /_/src/JsonApiDotNetCore/Middleware/AsyncQueryStringActionFilter.cs:line 29
         at async Task Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()+Awaited(?)
         at void Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Task Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
         at Task Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
         at async Task Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextExceptionFilterAsync()+Awaited(?)

@bkoelman
Copy link
Member

Thanks. Looks like QueryStringReader needs to skip over empty parameter names. Do you want to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants