Repository navigation
fix: report invalid SQS/SNS policy values as diagnostics - #46
Conversation
StringOrStringList, Principal and Condition threw ArgumentException from their Parse methods. The reader only catches AsyncApiException, so a malformed policy statement (e.g. `action` given as a map) escaped ReadFragment/Read instead of becoming a diagnostic. An empty principal map also threw InvalidOperationException from First(). Parse now throws AsyncApiReaderException with the parsing context, and an empty principal map is rejected through the same path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Problem
A malformed value in an SQS or SNS policy statement crashes the reader instead of producing a diagnostic:
StringOrStringList.Parse,Principal.ParseandCondition.Parse(both the SQS and SNS copies) threwArgumentException. The field parser andBindingDeserializer.LoadBindingsonly catchAsyncApiException, so the exception escapedReadFragment/Readand the caller got noReadResult/diagnostics at all.An empty principal map (
principal: {}) also threwInvalidOperationExceptionfrommapNode.First().Change
Parsemethods now throwAsyncApiReaderExceptionwith the parsing context, so the error is recorded indiagnostic.Errorswith a pointer, and reading continues.Principal.ParseusesFirstOrDefault()and treats an empty map as an invalid principal.StringOrStringListconstructor still throwsArgumentExceptionfor direct API misuse; only parsing changed.Tests
Added
AwsPolicyParsing_Should(10 cases) covering invalidaction,principal(scalar other than*, unknown key, empty map, list) andconditionvalues for SQS and SNS. All 10 fail onvnextand pass with this change; the full suite passes on net8.0/net9.0/net10.0.🤖 Generated with Claude Code
Summary by CodeRabbit