Azure / Azure/data-api-builder

[Bug]: Multiple REST API requests fail when "set-session-context": true

未关闭
#2,178 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug triage
主要语言
C#
星标
1.5k
派生
370
平均合并
3 天 22 小时
30 天内合并 PR
9

描述

### What happened?

When requesting for multiple api requests when session context is "set-session-context": true.
This is for using DB Type: DWSQL for using against Fabric SQL endpoints.

It causes the following api response:

{
"error": {
"code": "DatabaseOperationFailed",
"message": "Cannot set key 'aud' in the session context. The key has been set as read_only for this session.",
"status": 500
}
}

I am assuming the session is being sticky and not starting new sessions for each call.
For some reason it may be caching the session when "set-session-context": true, but from my understanding that should default to false.

### Version

0.11.130

### What database are you using?

Azure SQL

### What hosting model are you using?

Container Apps

### Which API approach are you accessing DAB through?

REST

### Relevant log output

```Text
fail: Azure.DataApiBuilder.Service.Controllers.RestController[0]
7c081014-1d46-44a5-ac17-d5a9e7532d8c Error handling REST request.
Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException: Cannot set key 'aud' in the session context. The key has been set as read_only for this session.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot set key 'aud' in the session context. The key has been set as read_only for this session.
at Microsoft.Data.SqlClient.SqlCommand.<>c.b__211_0(Task`1 result)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at Azure.DataApiBuilder.Core.Resolvers.QueryExecutor`1.ExecuteQueryAgainstDbAsync[TResult](TConnection conn, String sqltext, IDictionary`2 parameters, Func`3 dataReaderHandler, HttpContext httpContext, String dataSourceName, List`1 args)
ClientConnectionId:72047e37-8ca4-4d5c-9947-ebd8551d6518
Error Number:15664,State:1,Class:16
ClientConnectionId before routing:7783f539-dec7-4b05-810f-4a560d0de35b
Routing Destination:*****
--- End of inner exception stack trace ---
```

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

贡献指南

打开贡献指南

调研方向

首先使用提供的会话上下文配置和错误日志,跟踪 REST 请求经过 Azure.DataApiBuilder.Service.Controllers.RestController 和 Azure.DataApiBuilder.Core.Resolvers.QueryExecutor.ExecuteQueryAgainstDbAsync 的过程。针对 Azure SQL 重现多个请求,并确定为什么 'aud' 键会被多次设置为只读;当重复请求不再返回此 500 错误时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
azure, csharp, sql
领域
api, backend, databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。