Azure / Azure/data-api-builder

[Bug]: Wrong argument passed when validating stored-procedure query strings

Open
#3,551 0 comments 0 reactions 0 assignees View on GitHub
2.x rest
Dominant language
C#
Stars
1.5k
Forks
370
Avg merge
3d 17h
Merged PRs (30d)
8

Description

## What?

DAB reports “Primary key for POST requests can't be specified…”
instead of “Query string for this HTTP request type is an invalid URL.”

## Why?

```csharp
// (RestService.cs:311)
RequestValidator.ValidatePrimaryKeyRouteAndQueryStringInURL(EntityActionOperation.Insert, queryString);
```
### But the validator signature is:

```csharp
// (RequestValidator.cs:216)
ValidatePrimaryKeyRouteAndQueryStringInURL(operationType, primaryKeyRoute = null, queryString = null)
```

So queryString is being passed into the primaryKeyRoute parameter (positional argument bug), while the real queryString parameter is left null.

## Suggestion

Use named arguments.

```csharp
// RestService.cs:311
ValidatePrimaryKeyRouteAndQueryStringInURL(EntityActionOperation.Insert, primaryKeyRoute: null, queryString: queryString);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.