Azure / Azure/data-api-builder

[Bug]: GraphQL schema fails to initialize when stored procedure parameter defaults use non-numeric strings

Đang mở
#2,969 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
2.x
Ngôn ngữ chính
C#
Star
1.5k
Fork
372
Merge trung bình
3 ngày 22 giờ
Pull request đã merge (30 ngày)
9

Mô tả

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.

Image

**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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện cấu hình stored procedure với GraphQL được bật và kiểm tra GraphQLStoredProcedureBuilder.ConvertValueToGraphQLType, nơi xảy ra lỗi chuyển đổi được báo cáo. Xác nhận rằng các giá trị mặc định chuỗi không hợp lệ không còn ngăn cản việc khởi tạo schema GraphQL, bằng cách coi chúng là các giá trị literal hoặc tạo ra lỗi cấu hình rõ ràng trước khi khởi động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, graphql, sql
Lĩnh vực
api, databases
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.