Azure / Azure/data-api-builder
[Bug]: GraphQL schema fails to initialize when stored procedure parameter defaults use non-numeric strings
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 370
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 8
Description
When a stored procedure entity defines parameter defaults using non-numeric strings (for example `"default": "number"`), Data API builder fails to start with GraphQL enabled. The service throws a `DataApiBuilderException` during schema generation and `/graphql` becomes unavailable.
**Steps to Reproduce:**
1. Define a stored procedure entity like this:
```json
"GetSeriesActors": {
"source": {
"object": "dbo.GetSeriesActors",
"type": "stored-procedure",
"parameters": [
{ "name": "seriesId", "required": false, "default": "number" },
{ "name": "top", "required": false, "default": "number" }
]
},
"graphql": { "enabled": true, "operation": "mutation" }
}
```
2. Start DAB with GraphQL enabled.
3. Observe logs.
**Expected Behavior:**
DAB should either:
* Treat `"default": "number"` as a literal string value, or
* Reject invalid defaults during configuration validation with a clear error message before startup.
**Actual Behavior:**
DAB starts but fails when GraphQL initializes. The logs show:
```
DataApiBuilderException: The parameter value number provided in configuration cannot be converted to the type Int
System.FormatException: The input string 'number' was not in a correct format.
at System.Int32.Parse(String s)
```
After this error, `/graphql` is unavailable, though REST endpoints continue to function normally.
**Environment:**
* Data API builder version: 1.7.75
* Database: SQL Server
* Host: Azure Container Apps
* Authentication: StaticWebApps
**Notes:**
The exception originates from `GraphQLStoredProcedureBuilder.ConvertValueToGraphQLType` when attempting to parse the invalid default value. DAB should validate or sanitize stored procedure parameter defaults before GraphQL schema generation to prevent this runtime failure.
Contributor guide
Assessment
This issue has not been assessed yet.