https://mobileaws.atlassian.net/browse/CLOUD-2712#3
Open
dlopezallcode wants to merge 1 commit intomainfrom
Open
https://mobileaws.atlassian.net/browse/CLOUD-2712#3dlopezallcode wants to merge 1 commit intomainfrom
dlopezallcode wants to merge 1 commit intomainfrom
Conversation
8812891 to
22ac2ac
Compare
22ac2ac to
e9d4197
Compare
criscantillo
approved these changes
Apr 20, 2026
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.
Overview
Fixed two critical security/behavior bugs, removed a duplicate class, added typing corrections for Pylance/pyright, and configured the development environment. The SDK passes 39/39 unit tests with zero type errors.
Implemented Changes
1.
verify_signaturecorrection — security bug (src/ccai_python/webhook.py) 🔴Before: the implementation was a placeholder that always returned
True, accepting any signature without verification.After: real implementation with HMAC-SHA256:
hmac.compare_digest()for constant-time comparison (prevents timing attacks).sha256=prefix in signature.2. Hardcoded URL fix in Email Service (
src/ccai_python/email_service.py) 🔴Before: the service had the email URL hardcoded to the test environment, ignoring client configuration.
After: uses
self.ccai.email_base_urldynamically, which already handles test/prod switching correctly fromccai.py.3. Removal of duplicate
Accountclass (src/ccai_python/ccai.py)Before: a duplicate
Accountclass existed inccai.pythat duplicated the canonical class insms/sms.py, causing import confusion.After: the
Accountclass inccai.pywas removed. It is imported and re-exported fromsms/sms.py:Example scripts (
sms_send.py,mms_send.py) updated to import fromccai_python.sms.sms.4. Typing corrections for Pylance/pyright
All type errors reported by Pylance in
basicmode were fixed. No# type: ignoresilencers were used — all errors were corrected in the code.src/ccai_python/ccai.py:dataparameter ofrequest()changed toOptional[Union[Dict[str, Any], List[Any]]]to support webhook payload (array[{...}]).Union,Listtotypingimports.src/ccai_python/sms/sms.py:CCAIProtocol.request()updated to match actualCCAI.request()signature.SMSOptionsfixed: addedmodel_config = {"arbitrary_types_allowed": True}andField(default=None)on all optional fields.on_progresstyped asOptional[Callable[[str], None]](not builtincallable).30(avoidsint | None).src/ccai_python/sms/mms.py:CCAIProtocol.request()updated same assms.py.src/ccai_python/webhook.py:WebhookResponsemade fully optional withextra = "allow"— API doesn't always return all fields.**responsefixed with explicitdict(response)conversion.create_handlerreturns correctly typedCallable[[Dict[str, Any]], Dict[str, Any]].src/ccai_python/email_send.py,sms_send.py,mms_send.py:os.getenv()→os.environ['KEY']for required variables (avoidsstr | None).src/ccai_python/test_real.py:_to_dict(obj) -> dictadded: converts Pydantic models, dicts, or lists to first element dict..get()accesses go through_to_dict()first.res.do_not_text,res.phone).5. Pylance/pyright configuration (
pyrightconfig.json)Created in project root so Pylance resolves
src/layout imports correctly:{ "include": ["src", "tests"], "extraPaths": ["src"], "pythonVersion": "3.10", "typeCheckingMode": "basic" }Existing Features (Verified)
The following features were implemented before and verified to continue working:
send(),send_single()send(),send_single(),send_with_image(),get_signed_upload_url(),upload_image_to_signed_url(),check_file_uploaded()(with MD5 cache)send_campaign(),send_single()register(),update(),list(),delete(),verify_signature(),create_handler()set_do_not_text()use_test,base_url,email_base_url,file_base_urlwith test/prod switchingCompatibility Notes
Accountis still imported fromccai_python(re-exported) — backwards compatible for public imports.verify_signaturefix intentionally breaks previous behavior (alwaysTrue). Communicate in changelog.