fix(aws): don't panic on missing optional cluster_name in ECS log tools#237
Merged
Conversation
analyze_ecs_service_logs and get_ecs_task_logs read cluster_name with a bare type assertion; when the LLM omits the documented-optional field the value is a nil interface and the assertion panics. The dispatcher runs in unrecovered goroutines, so the panic crashes the process. Use the comma-ok form so the existing empty->default fallback handles it. Closes #207
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
analyze_ecs_service_logsandget_ecs_task_logsreadcluster_namewith a bare single-value type assertion (input["cluster_name"].(string)). The field is documented optional; when the LLM omits it, the map value is a nil interface and the assertion panics. The tool dispatcher runs inside goroutines with norecover(), so the panic crashes the whole process.Where
internal/aws/llm.go:1871(analyze_ecs_service_logs)internal/aws/llm.go:1914(get_ecs_task_logs)Fix
Use the comma-ok form (
clusterName, _ := input["cluster_name"].(string)); the existingif clusterName == "" { clusterName = "default" }fallback already handles the absent case — matching howservice_name/task_arnare read two lines above.Testing
go build ./internal/aws/andgo vet ./internal/aws/pass. (A panic-regression unit test needs AWS-CLI mocking ofexecuteAWSOperation; the fix is the standard comma-ok idiom and is self-contained.)Closes #207