-
Notifications
You must be signed in to change notification settings - Fork 124
[Integration][AWS] - Fix GeneralServiceException breaking resync on resource not found. #2287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Enhanced is_access_denied_exception() to detect access denied errors wrapped in GeneralServiceException by checking error message patterns - Enhanced is_resource_not_found_exception() to detect resource not found errors wrapped in GeneralServiceException by checking error message patterns - Added tests to validate GeneralServiceException error unwrapping behavior - Fixes resync failures when AWS wraps ResourceNotFoundException or AccessDenied errors inside GeneralServiceException Fixes PORT-16491
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…RT-16491-aws-generalserviceexception-unwrap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment
integrations/aws/utils/misc.py
Outdated
if error_code in resource_not_found_error_codes: | ||
return True | ||
|
||
if error_code == "GeneralServiceException": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t repeat yourself extract a function and pass the patterns on each occurrence
User description
Description
What
Improved AWS exception handling by enhancing
is_resource_not_found_exception()
andis_access_denied_exception()
to correctly detect cases where AWS CloudControl API returnsGeneralServiceException
wrapping underlying errors such asResourceNotFoundException
orAccessDenied.
Why
The AWS CloudControl API, which the integration sometimes uses to fetch and manage resource states, sometimes returns a top-level error code of GeneralServiceException even when the underlying issue is more specific — such as ResourceNotFoundException or AccessDenied.
In these cases, CloudControl wraps the actual downstream service error (for example, from EC2 or S3) inside the GeneralServiceException message string instead of exposing it as a structured error code. As a result, our existing helper functions — is_resource_not_found_exception() and is_access_denied_exception() — failed to recognize these conditions because they only checked the top-level error code.
This led to legitimate “not found” or “permission denied” cases being treated as unhandled exceptions, which interrupted the entire resync process rather than skipping the problematic resource and continuing graceful
Example of the problematic error:
How
is_resource_not_found_exception()
to check forGeneralServiceException
and inspect the error message for resource not found patterns: "not found", "notfound", "does not exist", "resourcenotfound"is_access_denied_exception()
to check forGeneralServiceException
and inspect the error message for access denied patterns: "access denied", "accessdenied", "unauthorized", "forbidden", "permission denied".lower()
Result: Resources with wrapped errors are now logged and skipped gracefully instead of breaking the resync, allowing the integration to continue processing remaining resources.
Type of change
Please leave one option from the following and delete the rest:
All tests should be run against the port production environment(using a testing org).
Integration testing checklist
examples
folder in the integration directory.Preflight checklist
Screenshots
Include screenshots from your environment showing how the resources of the integration will look.
API Documentation
Provide links to the API documentation used for this integration.
PR Type
Bug fix
Description
Enhanced AWS exception handling to detect errors wrapped in
GeneralServiceException
Added pattern matching for
ResourceNotFoundException
andAccessDenied
in error messagesPrevents resync failures by gracefully handling CloudControl API wrapped errors
Added comprehensive test coverage for new exception detection logic
Diagram Walkthrough
File Walkthrough
misc.py
Enhanced exception handlers to unwrap GeneralServiceException errors
integrations/aws/utils/misc.py
is_access_denied_exception()
to detect access denied patternsin
GeneralServiceException
messagesis_resource_not_found_exception()
to detect not foundpatterns in
GeneralServiceException
messagestest_misc.py
Added tests for GeneralServiceException error unwrapping
integrations/aws/tests/utils/test_misc.py
GeneralServiceException
with "does not exist" messagepattern
AccessDenied
wrapped inGeneralServiceException