Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion application_sdk/activities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ async def preflight_check(self, workflow_args: Dict[str, Any]) -> Dict[str, Any]
)

if not result or "error" in result:
raise ValueError("Preflight check failed")
raise ValueError(
"Preflight check failed: " + str(result.get("error", ""))
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Calling .get() on potentially None result

When result is None (or another falsy value), the code attempts to call result.get("error", "") which raises an AttributeError since None doesn't have a .get() method. The condition if not result or "error" in result short-circuits and enters the if block when result is falsy, but then tries to access .get() on that falsy value.

Fix in Cursor Fix in Web


logger.info("Preflight check completed successfully")
return result
Expand Down
5 changes: 3 additions & 2 deletions application_sdk/common/aws_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
logger = get_logger(__name__)


def get_region_name_from_hostname(hostname: str) -> str:
def get_region_name_from_hostname(hostname: str) -> str | None:
"""
Extract region name from AWS RDS endpoint.
Example: database-1.abc123xyz.us-east-1.rds.amazonaws.com -> us-east-1
Expand All @@ -28,7 +28,8 @@ def get_region_name_from_hostname(hostname: str) -> str:
match = re.search(r"-([a-z]{2}-[a-z]+-\d)\.", hostname)
if match:
return match.group(1)
raise ValueError("Could not find valid AWS region from hostname")
logger.warning("Could not find valid AWS region from hostname")
return None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Returning None region breaks downstream boto3 clients

Changing get_region_name_from_hostname to return None instead of raising ValueError causes downstream issues. When callers like generate_aws_rds_token_with_iam_role and generate_aws_rds_token_with_iam_user use the expression region or get_region_name_from_hostname(host), they'll pass None to boto3's region_name parameter if both region is None and the hostname doesn't contain a valid region. This will cause AWS SDK errors since boto3 requires a valid region to make API calls.

Additional Locations (2)

Fix in Cursor Fix in Web



def generate_aws_rds_token_with_iam_role(
Expand Down
Loading