Azure / Azure/data-api-builder
[Bug]: GraphQL schema fails to initialize when stored procedure parameter defaults use non-numeric strings
- Lenguaje dominante
- C#
- Estrellas
- 1.5k
- Forks
- 370
- Merge medio
- 3 d 22 h
- PR fusionados (30 d)
- 9
Descripción
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.
Guía de contribución
Línea de trabajo
Comience reproduciendo la configuración del procedimiento almacenado con GraphQL habilitado e inspeccione GraphQLStoredProcedureBuilder.ConvertValueToGraphQLType, donde se produce el fallo de conversión informado. Confirme que los valores predeterminados de cadena no válidos ya no impiden la inicialización del esquema GraphQL, ya sea tratándolos como valores literales o generando un error de configuración claro antes del inicio.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, graphql, sql
- Área
- api, databases
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100