Skip to content

Commit f354201

Browse files
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent dc0c37a commit f354201

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/Azure.DataApiBuilder.Mcp/BuiltInTools/CreateRecordTool.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,22 @@ public async Task<CallToolResult> ExecuteAsync(
131131
? dataElement.EnumerateObject().Select(property => property.Name)
132132
: Enumerable.Empty<string>();
133133

134-
if (!McpAuthorizationHelper.AreColumnsAuthorizedForOperation(
135-
authorizationResolver,
136-
entityName,
137-
effectiveRole!,
138-
EntityActionOperation.Create,
139-
requestedColumns,
140-
out string columnAuthError))
134+
try
135+
{
136+
if (!McpAuthorizationHelper.AreColumnsAuthorizedForOperation(
137+
authorizationResolver,
138+
entityName,
139+
effectiveRole!,
140+
EntityActionOperation.Create,
141+
requestedColumns,
142+
out string columnAuthError))
143+
{
144+
return McpErrorHelpers.PermissionDenied(toolName, entityName, "create", columnAuthError, logger);
145+
}
146+
}
147+
catch (Azure.DataApiBuilder.Service.Exceptions.DataApiBuilderException dabEx)
141148
{
142-
return McpErrorHelpers.PermissionDenied(toolName, entityName, "create", columnAuthError, logger);
149+
return McpResponseBuilder.BuildErrorResult(toolName, "ValidationFailed", $"Request validation failed: {dabEx.Message}", logger);
143150
}
144151

145152
JsonElement insertPayloadRoot = dataElement.Clone();

0 commit comments

Comments
 (0)