Skip to content

Commit 71672b4

Browse files
jpicklykclaude
andcommitted
fix: add foreign key validation to UpdateTaskTool
- Add pre-validation for featureId in UpdateTaskTool to check feature exists before update - Only validates when featureId is being changed to prevent unnecessary validation - Replaces raw SQL foreign key constraint errors with proper RESOURCE_NOT_FOUND responses - Consistent with CreateTaskTool validation approach 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a2a619b commit 71672b4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/kotlin/io/github/jpicklyk/mcptask/application/tools/task/UpdateTaskTool.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ class UpdateTaskTool(
266266
if (it.isEmpty()) null else UUID.fromString(it)
267267
} ?: existingTask.featureId
268268

269+
// Validate that referenced feature exists if featureId is being set/changed
270+
if (featureId != null && featureId != existingTask.featureId) {
271+
when (val featureResult = context.repositoryProvider.featureRepository().getById(featureId)) {
272+
is Result.Error -> {
273+
return errorResponse(
274+
message = "Feature not found",
275+
code = ErrorCodes.RESOURCE_NOT_FOUND,
276+
details = "No feature exists with ID $featureId"
277+
)
278+
}
279+
is Result.Success -> { /* Feature exists, continue */ }
280+
}
281+
}
282+
269283
val tags = optionalString(params, "tags")?.let {
270284
if (it.isEmpty()) emptyList()
271285
else it.split(",").map { tag -> tag.trim() }.filter { tag -> tag.isNotEmpty() }

0 commit comments

Comments
 (0)